nginxselect错误的默认网站

首先,我知道我可以指定default_server来强制一个默认网站,但我想了解为什么nginx不是简单地按照loggingselect第一个定义的server

在nginx.conf的http部分的末尾,我有

 include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; 

/etc/nginx/conf.d/*.conf只是一些默认的代理configuration和sslconfiguration

定义的网站是

000-default example.com zombo.com

默认站点指向本地目录和index.html,另外两个指向代理服务器。

000默认

 server { listen 80; server_name aaa-test; access_log /var/log/nginx/localhost.access.log; location / { root /var/www/nginx-default; index index.html index.htm; } } 

example.com

 server { server_name example.com *.example.com ; listen 80; location / { proxy_pass http://10.245.0.19; proxy_redirect default; } } 

zombo.com

 server { server_name zombo.com *.zombo.com ; listen 80; location / { proxy_pass http://10.245.0.36; proxy_redirect default; } } 

但是,如果我向nginx服务器IP浏览,我会从example.com得到一个答案。 我已经尝试重命名configuration文件以不同的顺序加载它们,并始终将example.com作为默认值。 即使我把它的configuration文件zzz.com

文档说没有主机头的stream量应该去第一个虚拟主机,但我似乎无法做到这一点。

如果我删除example.com,则stream量将转到默认主机,而不是zombo.com。

我真的很难过

编辑:通过评论请求的信息

 # ls -lU /etc/nginx/sites-enabled total 0 lrwxrwxrwx 1 root root 38 Oct 3 00:05 example.com -> /etc/nginx/sites-available/example.com lrwxrwxrwx 1 root root 34 Oct 3 00:05 000-default -> /etc/nginx/sites-available/default lrwxrwxrwx 1 root root 36 Oct 2 22:58 zombo.com -> /etc/nginx/sites-available/zombo.com 

nginx 正在查看第一个定义的server ,但它不是你认为的那个。

如果你运行了ls -lU /etc/nginx/sites-enabled你会看到磁盘上出现的实际顺序列表,这是它们将被读取的顺序。 这往往不是你所期望的顺序。

当然,这是你明确定义一个default_server原因之一。