Reputation: 29
I have two www directories in my nginx server. Directory 1 and directory 2.
Domain 1 one is configured to point to directory 1 and works as expected.
Domain2 is configured to point to directory 2, but instead points to directory 1.
Domain 1 -> Directory 1
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/sarasaworks.com/html;
index index.html index.htm index.nginx-debian.html;
server_name sarasaworks.com www.sarasaworks.com;
location / {
try_files $uri $uri/ =404;
}
Domain 2 -> Directory 2
server {
listen 80;
listen [::]:80;
root /var/www/snapdragonwellness.org/html;
index index.html index.htm index.nginx-debian.html;
server_name snapdragonwellness.org www.snapdragonwellness.org snapdragonwellness.com www.snapdragonwellness.com;
location / {
try_files $uri $uri/ =404;
}
Every thing looks exactly as it should, so I'm not quite sure what I should do to fix it...
Both directories have a dummy html file with unique hello world-like phrases to let me know everything works.
Upvotes: 0
Views: 982
Reputation: 78
Have you checked for a default server?
grep default_server /etc/nginx/ -r -C 3
maybe there is a catchall server block like
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/sarasaworks.com/html;
server_name _;
}
If the 2 server blocks are in different files each of these files need to be linked to from /etc/nginx/sites-enabled
you can check that with
ls /etc/nginx/sites-enabled/
Another thing I would try is running sudo nginx -t
to see if there are any errors in the configurations.
Good start to troubleshoot those problems is also to run sudo tail -f /var/log/access.log
or sudo tail -f /var/log/error.log/
to see what's going on.
While this is running you can reload/try to access the URL and see the logs.
More details on the errors can help us help you.
Upvotes: 2