Report this

What is the reason for this report?

NGINX Websites all point to same place

Posted on April 10, 2014

I followed this tutorial: https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3

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: http://pastebin.com/0yz3Lrwt

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

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 web1.com and web2.com 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.



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!

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.

Try using just one server block for each domain name. So there should only be two: server { <br> <br>sudo service nginx restart <br> <br>http://wiki.nginx.org/ServerBlockExample

Still the same problem as before unfortunately. Here’s the new one: <br>http://pastebin.com/ACnQ9pMv

Follow what was written on the NGINX wiki page you posted, I’ve now shortened the ‘sites’ file a bit, but I still have the same problem: <br>http://pastebin.com/0qpCfzkL

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.