Nginx warning "conflicting server name <domain_name> on 0.0.0.0:80, ignored"

raisinrising picture raisinrising · May 29, 2016 · Viewed 7.3k times · Source

I have looked across several forums and StackOverflow questions but I'm truly at a loss here as to why this is not working.

I was running a Ghost.org blog on a Digital Ocean droplet and had configured it according to this tutorial. I took a snapshot and destroyed the droplet a week ago. Everything is working fine at this moment.

Today, I created a fresh droplet with the same snapshot. Since the IP was different, I modified the domain settings accordingly and it was reflected on my computer as well. Then I try to access the website but the connection times out. Even after an hour or so, it times out, so I figures it's not DNS propogation at fault. A simple check on whatsmydns.net also confirms this is not the issue.

Upon further investigation, I find that /var/log/nginx/error.log has the following line in it - the only one for today's date:

2016/05/29 16:32:10 [warn] 988#0: conflicting server name "foobar.com.tld" on 0.0.0.0:80, ignored

I have checked the two configs I know could conflict - nginx.conf and sites-enabled/ghost (symlink to sites-available/ghost) for any conflicts - and I can't seem to find any.

I am not very comfortable with nginx - this is really my first exposure to it, but I've been banging my head for over 2.5 hours now and would really appreciate some help.

nginx.conf: http://pastebin.com/YUhBZVhX
sites-enabled/ghost: http://pastebin.com/3cdZgTG3
www/ghost/config.js: http://pastebin.com/iunffMzN

Edit: /etc/nginx/conf.d/ folder is empty, so there isn't a conflict there.

Edit 2: The simplest config:

server {
    listen 80;
    server_name foobar.com;
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}

doesn't seem to work either. I did restart the nginx service after making this change and also modified Ghost's config.js accordingly and restarted its service.

Edit 3: There are no hidden or backup files in the sites-enabled folder.

Answer

user2757283 picture user2757283 · Apr 10, 2019

Once you've confirmed that foobar.com isn't used in server_name anywhere else in your Nginx configs, look for $hostname or other Nginx variable, whose value might match your server_name:

Alphabetical index of Nginx variables

Example:

server {
    server_name localhost $hostname;
    listen 80;

    access_log off;
}

Got me puzzled there for a while.