1

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.

wedi
  • 358
  • 4
  • 12
  • Look for a symlink. My guess is you have symbolically linked something to `/etc/nginx/conf.d/autoconfig.example.com.conf` which is also being included. – Michael Hampton Mar 19 '19 at 01:00
  • Second guess, editor backup files in `..../sites-enabled/` – Alexey Ten Mar 19 '19 at 09:01
  • Unfortunately not. As I said: I checked multiple times and `nginx -T` does not overlook any hidden config file. – wedi Mar 19 '19 at 10:51
  • Why do you have this include at all? The config files specified would normally be included already by the existing include statement in the shipped nginx.conf. – Michael Hampton Aug 10 '20 at 16:53
  • Have the same problem. Funny thing is, that it's working though. I have two ssl subdomains on the same port and both respond correctly under their respective domains – GeeF Mar 19 '21 at 10:23

0 Answers0