Multiple domains on one server points to wrong sites Multiple domains on one server points to wrong sites nginx nginx

Multiple domains on one server points to wrong sites


Your nginx.conf loads its external server files from the path you have in your include directives.

If you have a file in include /etc/nginx/conf.d/*.conf; and its symlinked to include /etc/nginx/sites-enabled it's going to load the file twice which would cause that error.


I was having the same problem with my Ubuntu/nginx/gunicorn/django 1.9 sites on my local machine. I had two nginx files in my /etc/nginx/sites-enabled. Removing either one allowed to remaining site to work. Putting both files in ended up always going to one of the two sites. I'm not sure how it chose.

So after looking at several stack overflow questions without finding a solution I went here: http://nginx.org/en/docs/http/request_processing.html

It ends up that you can have multiple servers in one sites-enabled file, so I changed to this:

server {    listen 80;    server_name joelgoldstick.com.local;    error_log    /var/log/nginx/joelgoldstick.com.error.log debug;    location / {        proxy_pass http://127.0.0.1:8002;    }    location /static/ {        autoindex on;        alias /home/jcg/code/python/venvs/jg18/blog/collect_static/;    }}server {    listen 80;    server_name cc-baseballstats.info.local;    error_log    /var/log/nginx/baseballstats.info.error.log debug;    location / {        proxy_pass http://127.0.0.1:8001;    }    location /static/ {        autoindex on;        alias /home/jcg/code/python/venvs/baseball/baseball_stats/collect_static/;    }}

I can now access both of my sites locally


Check out the /etc/nginx/sites-enabled/ directory if there is any temp file such as ~default. Delete it and problem solved.

Credit: @OmarIthawi nginx error "conflicting server name" ignored