2015-05-24 98 views
0

我试图让nginx代理请求到Django服务器,但它一直显示nginx欢迎页面。nginx始终提供欢迎页面

这里的/etc/nginx/nginx.conf

worker_processes 4; 

events { 
    worker_connections 1024; 
} 

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

    sendfile  off; 

    tcp_nopush  on; 

    keepalive_timeout 65; 

    gzip on; 
    gzip_disable "msie6"; 

    include /etc/nginx/sites-enabled/*; 

    server { 
     listen 8000 default_server; 
     listen [::]:8000 default_server ipv6only=on; 
    } 
} 

和这里的/etc/nginx/sites-enabled/dotmanca(在site-enabled目录中唯一的文件):

server { 
    server_name _; 

    access_log off; 

    location /media/ { 
     alias /vagrant/media/; 
    } 

    location /static/ { 
     alias /vagrant/static/; 
    } 

    location/{ 
     proxy_pass http://127.0.0.1:8001; 
     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"'; 
    } 
} 
没有服务器在端口8001上运行

于是,我想到一个坏网关错误出现。相反,我看到默认的“欢迎使用nginx!”

运行sudo nginx -t给出如下:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 
nginx: configuration file /etc/nginx/nginx.conf test is successful 

此外,sudo service nginx restart显得无能为力。

我的nginx版本是1.4.6,它在Ubuntu Trusty上运行。

回答

0

所以从/etc/nginx/nginx.conf取出server部分并添加两个listen指令到server/etc/nginx/sites-enabled/dotmanca似乎工作。

或者至少,它允许sudo nginx -s reload解决问题。