我不知道如何解决运行时出现的以下警告nginx -t
:
2022/12/29 05:10:23 [warn] 24920#24920: conflicting server name "" on 0.0.0.0:80, ignored
2022/12/29 05:10:23 [warn] 24920#24920: conflicting server name "" on [::]:80, ignored
我的服务器上正在运行两个站点。
- 主页.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/home;
index index.html
server_name int.mycompany.lan;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
- 错误配置文件
server {
listen 80;
listen [::]:80;
root /var/www/bug;
index index.html
server_name bug.int.mycompany.lan;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
前往网站错误.int.mycompany.lan总是向我展示int.mycompany.lan网站。
如果我从 /etc/nginx/sites-enabled 中删除到其中一个文件的符号链接,或者将其中一个站点的端口更改为 8081 之类的端口,那么我就不会再收到上述错误。
答案1
愚蠢的错误。我删除了行上的分号index
。我花了几个小时才发现。