nginx domain resolves to incorrect site

March 31, 2014 3.8k views
I'm trying to host two domains on a single droplet. domainA.com and domainB.com domainA.com correctly shows content from /home/public/domainA/index.php correctly. domainB.com just shows domainA.com, whereas it should be showing the content of /home/public/domainB/index.php. Both domains are using digitaloceans nameservers, have an entry in sites-available and sites-enabled. domainA nginx config: server { listen 80; root /home/public/domainA/; index index.php index.html index.htm; server_name domainA.com www.domainA.com; ... domainB nginx config: server { listen 80 root /home/public/domainB/; index index.php index.html index.htm; server_name domainB.com www.domainB.com; ... Any help resolving this matter would be much appreciated! Thanks
5 Answers
Is that your entire configuration? You must have some PHP path for the .php files to work, ensure the root for that is set accordingly too.
This is just my quick resonse... Move the server name just below the port. Nginx reads configs in order, so that might make a difference... cause nginx would read... port 80... CHECK... go to this root (domainA). If you move it above you are doing Port 80... CHECK... domainA... FALSE... domainB.... CHECK...

semicolon is missing after this line of domainB.com's config:

listen 80
themadman300, no it's just the relevant snippet. I've pasted both configurations here if you'd like to see: http://codepaste.net/vjrses

Tony Tsang, copy paste error. The above URL has complete config.

bossryan, I'll try your suggestion. Thanks.
The config seems correct.

You can run sudo nginx -t to check config errors.

If no error found, the cause may be elsewhere.

You can try ls -l /etc/nginx/sites-enabled/
To check where the symlinks point to.

Or just delete domainA's link from sites-enabled and restart/reload nginx to see what happen.

Have another answer? Share your knowledge.