Python 未找到请求的URL(Django Nginx Gunicorn)

Python 未找到请求的URL(Django Nginx Gunicorn),python,django,nginx,gunicorn,Python,Django,Nginx,Gunicorn,在尝试访问根url以外的任何url时,我遇到以下错误: Not Found The requested URL /groups/test/ was not found on this server. 我认为问题可能出在以下某个方面: URL.py: from django.conf.urls import include, url from django.contrib import admin from groups import views urlpatterns = [ #

在尝试访问根url以外的任何url时,我遇到以下错误:

Not Found

The requested URL /groups/test/ was not found on this server.
我认为问题可能出在以下某个方面:

URL.py:

from django.conf.urls import include, url
from django.contrib import admin

from groups import views

urlpatterns = [
    # Examples:
    url(r'^$', views.home_page, name='home'),
    url(r'^groups/(.+)/$', views.view_group, name='view_group')
]
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;
    }
}
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
这应该如何解决

编辑:

gunicorn upstart模板:

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;
    }
}
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

您的
位置/
应该重定向到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"';
    }
位置/{
代理通行证http://127.0.0.1:;
代理\u集\u头X转发主机$server\u名称;
代理集头X-Real-IP$remote\u addr;
添加标题P3P'CP=“所有DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV”;
}

您的
位置/
应重定向到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"';
    }
位置/{
代理通行证http://127.0.0.1:;
代理\u集\u头X转发主机$server\u名称;
代理集头X-Real-IP$remote\u addr;
添加标题P3P'CP=“所有DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV”;
}

我还将添加设置gunicorn的upstart文件。我想unix套接字已经在做你说的事情了根URL工作正常,我不知道我怎么会重定向到错误的端口。我还将添加我的upstart文件来设置gunicorn。我想unix套接字已经在做你说的事情了根URL工作正常,我不知道我怎么会重定向到错误的端口。我还将添加我的upstart文件来设置gunicorn。我认为unix套接字已经在做你所说的事情了根URL工作得很好,我不知道我怎么会重定向到错误的端口