Why is nginx displaying the wrong website on my server? -
i have 2 websites: default-website.com, second-website.com.
when go second-website.com seeing default-website.com. not understand why happening. note default-website.com displays normal.
this setup:
dns set both point @ same ip address.
they both have own unique websites:
/var/www/default-website.com/public_html/index.html /var/www/second-website.com/public_html/index.html
this contents of /etc/nginx/sites-enabled:
lrwxrwxrwx root root default-website.com -> /etc/nginx/sites-available/default-website.com lrwxrwxrwx root root second-website.com -> /etc/nginx/sites-available/second-website.com
this contents of /etc/nginx/sites-available/default-website.com:
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/default-website.com/public_html; index index.html index.htm; server_name default-website.com; location / { try_files $uri $uri/ =404; } }
this contents of /etc/nginx/sites-available/second-website.com:
server { listen 80; listen [::]:80; root /var/www/second-website.com/public_html; index index.html index.htm; server_name second-website.com; location / { try_files $uri $uri/ =404; } }
can see wrong here? appears set correctly.
thank help.
i figured out.
i needed add "www." version of domain name nginx website config.
so needed make change:
server_name second-website.com www.second-website.com;
it seems if tried go www.second-website.com couldn't find it, load default website default-website.com.
i able detect trying load second-website.com (loaded correctly) instead of www.second-website.com (redirected default-website.com).
Comments
Post a Comment