简体   繁体   English

nginx:[警告] 0.0.0.0:80 上的冲突服务器名称“example.com”,已忽略

[英]nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignored

When I'm trying to restart nginx, I'm getting the following error当我尝试重新启动 nginx 时,出现以下错误

nginx: [warn] conflicting server name "example.io" on 0.0.0.0:80, ignored

I used my deploy scripts, to do deploying for 2 domains.我使用我的部署脚本为 2 个域进行部署。 For first it works fine, but for second, it gives error.首先,它工作正常,但其次,它会出错。

Here is my nginx.conf file这是我的 nginx.conf 文件

#
worker_processes 2;

#
user nginx nginx;

#
pid /opt/nginx/pids/nginx.pid;
error_log /opt/nginx/logs/error.log;

#
events {
    worker_connections  4096;
}

#
http {
    #
    log_format full_log '$remote_addr - $remote_user $request_time $upstream_response_time '
                        '[$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';

    #
    access_log  /opt/nginx/logs/access.log;

    ssl on;
    ssl_certificate /opt/nginx/cert/example.crt;
    ssl_certificate_key /opt/nginx/cert/example.key;

    #
    include /opt/nginx/conf/vhosts/*.conf;

    # Deny access to any other host
    server {
        server_name example.io;  #default
        return 444;
    }
}

Any how your domain name is added in您的域名是如何添加的

/etc/nginx/sites-enabled/default

To confirm search using确认搜索使用

grep -r mydomain.com /etc/nginx/sites-enabled/*

and remove the domain name.并删除域名。

Then restart Nginx using然后使用重启 Nginx

sudo systemctl restart nginx

Not sure,but try changing server name in不确定,但尝试更改服务器名称

/etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/default

it should help它应该有帮助

Juste change listen 80 to another number like 8000 or 5000, whatever but not 80. For good job, don't edit nginx.conf itself, create your own file.conf and link it.只需将 listen 80 更改为另一个数字,例如 8000 或 5000,无论是什么,但不是 80。为了做好工作,不要编辑 nginx.conf 本身,创建您自己的 file.conf 并链接它。 following this link .按照这个链接 to see clearly what i means.清楚地看到我的意思。

I had got the same problem.我遇到了同样的问题。 To resolve this, I looked for conflict domain "example.io" in conf files.为了解决这个问题,我在 conf 文件中查找了冲突域“example.io”。

In the following file, there was a snippet added for "example.io" at the bottom.在以下文件中,在底部为“example.io”添加了一个片段。 " default_server " server section was as it is but section was added at the end of the file. default_server ” 服务器部分保持原样,但在文件末尾添加了部分。

/etc/nginx/sites-available/default /etc/nginx/sites-available/default

server {
       listen 80;
       listen [::]:80;

       server_name example.io;

       root /var/www/html;
       index index.html;

       location / {
               try_files $uri $uri/ =404;
       }
}

So I think you need to search server_name in all files which reside inside " /etc/nginx/sites-available " folder.因此,我认为您需要在“ /etc/nginx/sites-available ”文件夹中的所有文件中搜索 server_name 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM