All domains go to same site, not following NGINX conf files

October 13, 2013 2.2k views
I have three domains set up. One points to /var/www (my Ghost install) and works correctly. After a lot of troubleshooting my other two test domains now resolve, but they go to the /var/www location instead of the locations specified in their configuration files. Both .conf files include this: listen 80; root /var/www/domainname.com; index index.php index.html index.htm; server_name domainname.com; Why are these configuration files not working?
5 Answers
Did you create symbolic links for all three domains in /etc/nginx/sites-enabled/? This tutorial may be of assistance: How To Set Up nginx Virtual Hosts (Server Blocks) on Ubuntu 12.04 LTS.
by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one website or domain off of a single server and IP address. When used with nginx, virtual hosts are called Server Blocks. This tutorial covers setting up server blocks on an Ubuntu server.
Have you restarted Nginx? If so, what's the output of ls -la /var/www/?
Please pastebin all of your virtualhosts and the output of the command Pablo posted.
I had the same problem. And after restarting the server nginx would not start!
I got this error: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
When I increased server_names_hash_bucket_size to 64 nginx started and the problem I had before disappeared.

Hope it helps.
Have another answer? Share your knowledge.