Second domain on same droplet NOT working with NginX

  • Posted on August 2, 2014
  • sim4bizAsked by sim4biz

I’m trying to use my NginX to host multiple websites on the same droplet. I can access and with or without the use of default_server tag. However, accessing just presents the contents of (the server block with the default_server tag) without forwarding the url to in the browser. I’ve checked for typo in my configs but can’t find one. Secondly, neither the access.log nor the error.log have any issues.

The hostname of my droplet is I’ve created 2 DNS entries: 1 for and the other for Both have the same A and CNAME records.

@      A
www    CNAME  @
*      CNAME  @

My configs are: /etc/nginx/nginx.conf: /etc/nginx/global/wordpress.conf: /etc/nginx/global/restrictions.conf: /etc/nginx/sites-available/sites.conf:

Any clues?

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.

Read it first: Virtual Host Nginx: Ubuntu or Virtual Host Nginx: CentOS And do the same with the next domain.

Configuration server_name and server_name must be separated.

On your pastebin, you must remove server_name first and make a second configuration for the server_name

And add your second/next domain on your hosts. Then edit /etc/hosts. Make it look like this:

sudo nano /etc/hosts       localhost.localdomain   localhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

This comment has been deleted

Thanks for replying. The problem was that I only had in server_name in the site vhost but I was trying to access it without www. I now added the extra server block with return directive to take care of non-www.