找不到请求的URL(Django Nginx Gunicorn)

2024-10-02 14:16:20 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试访问根url之外的任何url时,出现以下错误:

Not Found

The requested URL /groups/test/ was not found on this server.

我认为问题可能出在以下某个方面:

在网址.py公司名称:

^{pr2}$

在nginx.conf公司模板:

server {
    listen 80;
    server_name SITENAME;

    location /static {
        alias /home/ghust1995/sites/SITENAME/static;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://unix:/tmp/SITENAME.socket;
    }
}

该如何修复?在

编辑:

gunicorn新贵模板:

description "Gunicorn server for SITENAME"

start on net-device-up
stop on shutdown

respawn

setuid ghust1995
chdir /home/ghust1995/sites/SITENAME/source

exec ../virtualenv/bin/gunicorn --bind unix:/tmp/SITENAME.socket itagroups.wsgi:application

Tags: 模板httpurlhomeserveron公司static
1条回答
网友
1楼 · 发布于 2024-10-02 14:16:20

您的location /应该重定向到Gunicorn运行的端口。在

location / {
            proxy_pass http://127.0.0.1:<Gunicorn Port>;
            proxy_set_header X-Forwarded-Host $server_name;
            proxy_set_header X-Real-IP $remote_addr;
            add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }

相关问题 更多 >

    热门问题