2013-04-30 22 views
0

我需要使用ngnix和uwsgi部署我的django站點。它在localhost中工作正常。但是當我給我的遠程服務器,它不起作用。這是我的ngnix.conf文件Django,ngnix和uwsgi站點無法在遠程服務器上部署

# nginx.conf 
    upstream django { 
     # connect to this socket 
     server unix:///tmp/uwsgi.sock;  # for a file socket 
     #server 127.0.0.1:8001;  # for a web port socket 
     } 

    server { 
     # the port your site will be served on 
     listen  80; 
     # the domain name it will serve for 
     server_name 192.168.101.191;  # substitute your machine's IP address or FQDN 
     charset  utf-8; 

     #Max upload size 
     client_max_body_size 75M;  # adjust to taste 

     # Django media 
     location /media { 
        alias /home/calcey/django_env_2/employee/media;  # your Django project's media files 
     } 

      location /static { 
        alias /home/calcey/django_env_2/employee/static;  # your Django project's static files 
      } 

     # Finally, send all non-media requests to the Django server. 
     location/{ 
      uwsgi_pass django; 
      include  /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually 
      } 



     } 

「192.168.101.191」表示我的服務器IP地址。如果我把本地主機,而不是「192.168.101.191」它的作品。但對於遠程IP,它不起作用。請給我一個建議。

+0

「不起作用」是什麼意思?你見過日誌嗎?請嘗試用更多細節來解釋問題。 – TheBronx 2013-04-30 11:21:33

回答

0

您的服務器IP地址看起來像某種Internal IP。但無論如何,只要Nginx腳本在服務器上運行,就不需要任何服務器IP地址。

您可以改用以下配置:

Server { 
    listen 80; 
    server_name 127.0.0.1; 
    .... 
    .... 
    .... 
} 

希望這將解決您的問題。