nginx:服务器名称再次发生冲突

nginx:服务器名称再次发生冲突

nginx冲突的服务器名称。这出现在几个问题中,但没有一个符合我的情况,请参见下文。

在 nginx 启动时我收到如下消息

[warn] 1#1: conflicting server name "autoconfig.example.com" on 0.0.0.0:443, ignored

一切似乎按预期工作。

我的配置

nginx.conf:

server {
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name _;
  return 301 https://mail.myserver.de$request_uri;
}

include /etc/nginx/conf.d/autoconfig.*.conf;

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name mail.myserver.de mail01.myserver.de;

  ssl_certificate /etc/ssl/myserver.de.pem;
  ssl_certificate_key /etc/ssl/myserver.de.key;

  [...]
}

包含的文件如下所示:

/etc/nginx/conf.d/autoconfig.example.com.conf

server {
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name autoconfig.example.com autodiscover.example.com;

  ssl_certificate /etc/ssl/example.com.pem;
  ssl_certificate_key /etc/ssl/example.com.key;

  [...]

  return 301 https://mail.myserver.de$request_uri;
}

nginx 错误消息

当 nginx 启动时,我收到每个包含的配置的以下错误消息:

2019/03/18 20:17:40 [warn] 1#1: conflicting server name "autoconfig.example.com" on 0.0.0.0:443, ignored
2019/03/18 20:17:40 [warn] 1#1: conflicting server name "autodiscover.example.com" on 0.0.0.0:443, ignored
2019/03/18 20:17:40 [warn] 1#1: conflicting server name "autoconfig.example.com" on [::]:443, ignored
2019/03/18 20:17:40 [warn] 1#1: conflicting server name "autodiscover.example.com" on [::]:443, ignored

我如何检查我的配置

我反复检查了配置中是否有重复的主机名,但还是没有发现。我多次手动检查并使用以下命令:

/ # nginx -T 2> /dev/null | grep example.com
# configuration file /etc/nginx/conf.d/autoconfig.example.com.conf:
  server_name autoconfig.example.com autodiscover.example.com;
  ssl_certificate /etc/ssl/autoconfig/example.com/cert.pem;
  ssl_certificate_key /etc/ssl/autoconfig/example.com/privkey.pem;
  ssl_trusted_certificate /etc/ssl/autoconfig/example.com/ca.pem;

/ # grep -r example.com /etc/nginx/
/etc/nginx/conf.d/autoconfig.example.com.conf:  server_name autoconfig.example.com autodiscover.example.com;
/etc/nginx/conf.d/autoconfig.example.com.conf:  ssl_certificate /etc/ssl/autoconfig/example.com/cert.pem;
/etc/nginx/conf.d/autoconfig.example.com.conf:  ssl_certificate_key /etc/ssl/autoconfig/example.com/privkey.pem;
/etc/nginx/conf.d/autoconfig.example.com.conf:  ssl_trusted_certificate /etc/ssl/autoconfig/example.com/ca.pem;

我的问题

为什么我的情况会出现这些警告?

我是否错过了检查重复主机的方法server_name

我该如何进一步调试这个问题?

您能想到这种配置可能不起作用的情况吗?

有没有办法让我的秩序感快乐并摆脱这些信息?

相关问题

我发现的其他问题与我的问题不符。我没有在两个服务器块中提及域,并且我的所有块都指定了服务器名称。

相关内容