Report this

What is the reason for this report?

Can we host multiple websites in nginx at localhost?

Posted on August 1, 2013

I have a general question about nginx

Let say you don’t have a domain first, but you already fired up your droplets. You already success setup Nginx in your droplet.

But your plan is to host 2 website in the droplet So the first website is done, assuming the default nginx page is the first website.

Now, how can i host the second website? Remember for now i still dont have the domains. What to put in the nginx configuration (server_name) for the second website?

For the first website, i already use “server_name localhost;”

What sould i put for the second website?



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.

Just add some bogus domains to your ‘hosts’ file in the droplet. set up nginx using those. Then add them to your client machine ‘hosts’ file also. Now your bogus domains are available to you only and work in nginx.

Have you taken a look at this tutorial: <a href=“https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3”>How to Set Up nginx Virtual Hosts (Server Blocks) on Ubuntu 12.04 LTS</a>?

i did, but that tutorial assuming you already have a domain, or point to ip address. Its not answering my question here

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.