NGINX Websites all point to same place

  • Posted on April 10, 2014
  • shaunAsked by shaun

I followed this tutorial:

I have two websites: web1 and web2 and their respective directories on the droplet are:

  1. /var/www/web1/public_html
  2. /var/www/web2/public_html

In my sites-available directory I have a file called ‘sites’. The contents of the file is here:

I have two files in the /etc/nginx/global directory: common.conf and wordpress.conf. - The contents of each is: Common.conf: Wordpress.conf:

I created a symbolic link from sites-available to sites-enabled and I have checked inside the sites-enabled directory and the only link in there is the one for the ‘sites’ file.

In the public_html directory for web2, I have index.html containing the following HTML: <html><body><h1>Site 2</h1><p>Working</p></html>

The problem is that when I go to both and it comes up with the following text: “Site 2 Working”. It seems like web1 and web2 are both pointing to /var/www/web2/public_html, when web1 should be pointing to /var/www/web1/public_html

Anyone have any ideas? I’ve been stuck on this for a couple of days and can’t work out how to get past it.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

And you add the domains to the hosts? My problem was the server name, but not your case.

Any ideas anyone?

I tried what you guys have said but to no avail. I reinstalled nginx and have redone the configs to something much simpler than before. I’ve also split each site into a separate file to make things simpler. <br> <br>Here are the 3 nginx files I’ve modified: <br>- /etc/nginx/nginx.conf: <a href=“”>Pastebin</a> <br>- /etc/nginx/sites-available/web1: <a href=“”>Pastebin</a> <br>- /etc/nginx/sites-available/web2: <a href=“”>Pastebin</a> <br> <br>I’ve created the soft symbolic links for web1 and web2, pointing to the /etc/nginx/sites-enabled directory. I also deleted the default one in sites-enabled. <br> <br>With these configs, I still have the same problem as before with, and the IP address of the droplet all pointing to the index.html file inside the web1 directory. Preferably, the IP of the droplet would go nowhere and the two domains would point to the correct directories. <br> <br>Any ideas? I’m completely stuck.