nginx and conflicting server name. This comes up in a few questions but none of those match my case, see below.
On nginx startup I get messages like this
[warn] 1#1: conflicting server name "autoconfig.example.com" on 0.0.0.0:443, ignored
Everything seems to work as expected.
My Configuration
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;
[...]
}
The included files look like this:
/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 error messages
When nginx starts up, I get the following error messages for every included configuration:
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
How I checked my config
I triple checked my config for duplicated host names and haven't found any. Multiple times I checked manually and with the following commands:
/ # 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;
My Questions
Why do these warnings show up in my case?
Have I missed a way to check for duplicated hosts in server_name
?
How can I further debug this issue?
Can you think of any cases where this config might not work?
Is there a way to make my sense of order happy and get rid of these messages?
Related Questions
The other questions I found do not match my problem. I do not mention a domain in two server blocks and all my blocks have server names specified.
- Multiple Domains Name on one server with Nginx
Solution: two different server blocks with the same server_name - How to make NGINX redirect from http to https?
Solution: two server blocks listening for SSL on the same port with the same server name - nginx: [warn] conflicting server name
Solution: 2 server statements using the same server_name - Nginx conflicting server name for subdomain
Solution: https blocks need server names specified too