nginx始终提供欢迎页面 [英] nginx always serves welcome page
问题描述
我正在尝试向Django服务器发出nginx代理请求,但它一直显示nginx欢迎页面.
I'm trying to make nginx proxy requests to a Django server, but it keeps showing the nginx welcome page.
这里是/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
目录中的唯一文件):
and here's /etc/nginx/sites-enabled/dotmanca
(the only file in the site-enabled
directory):
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!"
So with no server running on port 8001, I expect a bad gateway error to show up. Instead I see the default "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上运行.
My nginx version is 1.4.6, and it's running on Ubuntu Trusty.
推荐答案
因此,从/etc/nginx/nginx.conf
中删除server
部分并将两个listen
指令添加到/etc/nginx/sites-enabled/dotmanca
中的server
部分中似乎是可行的.
So removing the server
section from /etc/nginx/nginx.conf
and adding the two listen
directives to the server
section in /etc/nginx/sites-enabled/dotmanca
appears to work.
或者至少,它允许sudo nginx -s reload
解决该问题.
Or at least, it allows sudo nginx -s reload
to fix the issue.
这篇关于nginx始终提供欢迎页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!