nginx 始终提供欢迎页面

nginx always serves welcome page

我正在尝试向 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/dotmancasite-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 上没有服务器 运行,我预计会出现错误的网关错误。相反,我看到默认的 "Welcome to 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 上。

因此从 /etc/nginx/nginx.conf 中删除 server 部分并将两个 listen 指令添加到 /etc/nginx/sites-enabled/dotmanca 中的 server 部分似乎有效。

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