Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

if I don't have an domain and what I have is IP address.. how can I create a virtual host? can someone give me an example of a nginx.conf file?

share|improve this question
up vote 0 down vote accepted

Use hosts file. Add server directive to nginx config:

server {
    root /var/www/;

Create /var/www/

# mkdir /var/www/
# echo " virtualhost" >> /var/www/

Add to your local system hosts files(%SystemRoot%\system32\drivers\etc\ in Windows):

#echo "IP" > /etc/hosts

Also you can use DynDNS.

share|improve this answer
so then to access I can do IP/example – EquinoX Feb 28 '11 at 6:21
No. You need use DNS name. Web bowser add Host header when you use DNS name. Nginx use Host header to route virtual hosts. – ooshro Feb 28 '11 at 6:22
can you show what you mean by that? – EquinoX Feb 28 '11 at 6:27
Create and virtual hosts with different content. Then open "" and "", you see different web site. – ooshro Feb 28 '11 at 6:29
well...I want to be able to access it from outside the server – EquinoX Feb 28 '11 at 6:35

You either need to use a non name based virtual host at which point you can only have one site per IP address, in this case you can just type the IP into your webbrowser. The default nginx config on most systems should already have this setup for you

If you want to put more than site on an IP you have to use name based virtualhosts, you set these up as normal if you did have a domain name, but to be able to see them you would have to edit your hosts file to add the domain records you set your virtualhosts on. You would have to do this on every computer you want to access those sites from and it does require admin privileges to each machine

NOTE: you dont actually need to own the domains you use, but i would recommend it or at least not using common domains

share|improve this answer

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.