nginx+gunicorn部署django, 每次post之后都会跳转到本地链接, 求指教

发布于 2022-08-25 11:39:14 字数 1480 浏览 20 评论 0

如题, nginx+gunicorn部署django, 每次post之后都会跳转到本地链接

环境 ubuntu server 12.04 + nginx1.0.15 + django1.5

django view 见 http://django-china.cn/topic/123/

nginx配置文件

worker_processes 1;

user nobody nogroup;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;

events {
    worker_connections 1024;
    accept_mutex off;
}

http {
    include mime.types;
    default_type application/octet-stream;
    access_log /tmp/nginx.access.log combined;
    sendfile on;

upstream app_server {
    server unix:/tmp/gunicorn.sock fail_timeout=0;
    # For a TCP configuration:
    # server 192.168.0.7:8000 fail_timeout=0;
}

server {
    listen 80 default;
    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # path for static files
    root /path/to/app/current/public;

    location / {
        # checks for static file, if not found proxy to app
        try_files $uri @proxy_to_app;
    }

    location @proxy_to_app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        proxy_pass   http://app_server;
    }

    error_page 500 502 503 504 /500.html;
    location = /500.html {
        root /path/to/app/current/public;
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文