【问题标题】:nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignorednginx:[警告] 0.0.0.0:80 上的服务器名称“example.com”冲突,已忽略
【发布时间】:2017-02-06 18:00:14
【问题描述】:

当我尝试重新启动 nginx 时,出现以下错误

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

我使用我的部署脚本为 2 个域进行部署。首先它工作正常,但第二个它给出了错误。

这是我的 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;
    }
}

【问题讨论】:

  • 从名为nginx.conf 的文件开始,查看server 块和include 语句。您可能正在读取一个备份文件,这意味着 nginx 在端口 80 上看到相同的 server_name 两次。
  • @RichardSmith 我编辑我的问题并添加 nginx.conf 文件
  • @RichardSmith 你是对的。问题来自我在 server_name 块和包含语句中的子域 conf 文件之一。

标签: python django nginx deployment


【解决方案1】:

我遇到了同样的问题。为了解决这个问题,我在 conf 文件中查找了冲突域“example.io”。

在下面的文件中,在底部为“example.io”添加了一个sn-p。 “default_server”服务器部分保持原样,但在文件末尾添加了部分。

/etc/nginx/sites-available/默认

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

       server_name example.io;

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

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

所以我认为您需要在“/etc/nginx/sites-available”文件夹中的所有文件中搜索 server_name。

【讨论】:

    【解决方案2】:

    只需将 listen 80 更改为另一个数字,例如 8000 或 5000,但不是 80。 为了做得好,不要编辑 nginx.conf 本身,创建自己的 file.conf 并链接它。关注此link。看清楚我的意思。

    【讨论】:

      【解决方案3】:

      不确定,但尝试更改服务器名称

      /etc/nginx/sites-enabled/default

      应该有帮助

      【讨论】:

      • 是的,对我有用!我尝试了其他一些配置方式,但我忘了删除默认值。谢谢!
      猜你喜欢
      • 1970-01-01
      • 2020-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-10
      • 1970-01-01
      • 2020-06-15
      • 1970-01-01
      相关资源
      最近更新 更多