2012-10-15 65 views
1

這是我第一次使用django + nginx + gunicorn。我無法讓server_name工作。通過以下配置,我可以在localhost/admin中查看django管理面板。但是當我訪問local-example/admin時,我應該能夠看到管理面板嗎?服務器名稱不起作用(django + nginx + gunicorn)

開始我gunicorn

gunicorn web_wsgi_local:application 
2012-10-14 19:45:50 [16532] [INFO] Starting gunicorn 0.14.6 
2012-10-14 19:45:50 [16532] [INFO] Listening at: http://127.0.0.1:8000 (16532) 
2012-10-14 19:45:50 [16532] [INFO] Using worker: sync 
2012-10-14 19:45:50 [16533] [INFO] Booting worker with pid: 16533 

nginx.conf

worker_processes 1; 

events { 
    worker_connections 1024; 
} 


http { 
    include  mime.types; 
    default_type application/octet-stream; 

    log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
        '$status $body_bytes_sent "$http_referer" ' 
        '"$http_user_agent" "$http_x_forwarded_for"'; 

    access_log /Users/ruixia/www/x/project/logs/nginx_access.log main; 
    error_log /Users/ruixia/www/x/project/logs/nginx_error.log debug; 

    autoindex on; 
    sendfile  on; 
    tcp_nopush  on; 
    tcp_nodelay off; 

    gzip on; 

    include /usr/local/etc/nginx/sites-enabled/*; 
} 

/X配置

server { 
    listen 80; 
    server_name local-example; 
    root /Users/ruixia/www/x/project; 

    location /static/ { 
     alias /Users/ruixia/www/x/project/static/; 
     expires 30d; 
    } 

    location /media/ { 
     alias /Users/ruixia/www/x/project/media/; 
    } 

    location/{ 
     proxy_pass_header Server; 
     proxy_set_header Host $http_host; 
     proxy_redirect off; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Scheme $scheme; 
     proxy_connect_timeout 10; 
     proxy_read_timeout 10; 
     proxy_pass http://localhost:8000/; 
    } 
} 

回答

0

呃......我解決它通過添加本地例子啓用的站點 -/etc/hosts

+0

我正在尋找解決方案上面類似的問題。我無法使用web服務器或主機名的ip地址在網絡內遠程訪問我的django。我已經在/ etc/hosts中添加了Web服務器名稱。我在我的防火牆中添加了端口以打開。任何指針真的很感激。 – Charlesliam

相關問題