Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am confused of understanding the concept of virtual host in nginx server... so basically this is used for multiple websites in the nginx server. Part of the tutorial is below:

enter image description here

It shows there that it can open, this is possible because it is in the browser. So, lets say that this server is on ip and I can only access this server via terminal, there is no way that I can access that right? And so no one else will be able to see that

Maybe my question is that, does every virtual host need a hostname so that every person in earth can access it? If not then how is it possible with one IP address I have...

share|improve this question
up vote 0 down vote accepted

If you dont have DNS setup for then no one will be able to see that content unless they also use the hosts trick you mention for testing.

virtualhost names are mainly for getting around the sharing IP's issue, if every vhost was on its own IP then if you navigated by IP address then you dont strictly need hostnames for each one (although you still need a vhost for each site, unless you do some other multi-domain hosting)

I would also argue that its a good idea to use hostnames where possible if you are going to use DNS so that you dont have to get an IP for every different site you need to host

For your question, you will need to use hostname values for every site if you are using just one IP address

share|improve this answer
so usually when you setup a virtual host user have a domain already pointing out to that server? – EquinoX Feb 28 '11 at 14:13
no you dont have to, virtual hosts just allow you to host more than one site on a single IP it does so by tracking the name you put in as your url, itself it doesnt need dns working to work however you do need someway of making the name you set connect to that IP, hence using the hosts file or dns – anthonysomerset Feb 28 '11 at 15:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.