2015-06-21 65 views
1

我在嘗試訪問除了根的網址的時候出現以下錯誤:請求的URL沒有創立(Django的Nginx的Gunicorn)

Not Found 

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

我想問題可能是下列之一:

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

這應該如何解決?

編輯:

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 

回答

0

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"'; 
    } 
+0

我還會添加我的upstart文件,設置gunicorn。我認爲unix套接字已經在做你說的 –

+0

根URL的工作正常,我沒有看到我可以重定向到錯誤的端口 –