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 have an Apache web server hosting a few Django sites using the same domain name but different sub-domains:

The apache configuration file of each of the above begins like the following:

<VirtualHost *:80>

Assuming the external IP of the server is 200.x.x.x and its internal IP is 10.x.x.x Which of those two IP should I use if I want to add a new sub-domain name( to the server? I usually do the web dev and basic apache configuration, I'm still fuzzy on what's happening beyond that. Can someone give me a thorough explanation on what need to be setup and what is going on once I have setup the apache configuration file for a new site?

share|improve this question
up vote 1 down vote accepted

To quickly answer your question, , you don't need to worry about the IP address for your configuration, the domain name/alias is all you have to worry about, as apache will use the HTTP_HOST header passed by the browser.

<VirtualHost *:80>
    DocumentRoot /path/to/proj1
<VirtualHost *:80>
    DocumentRoot /path/to/proj2
<VirtualHost *:80>
    DocumentRoot /path/to/proj3

Long winded explanation.

In lamen terms, there are 2 seperate things going on here.

  1. resolving a domain name to an IP
  2. sending a web request to a server with virtual hosts set up

Resolving a domain name to an IP

when a browser is told to pull up a page, the first thing it does is do a DNS lookup for The DNS requests first it goes to the ROOT servers, and says "who controls", then the root servers point to the DNS server that controls .com domains, and says to that DNS Server and says "who controls", then it goes to your DNS server, and goes "What's the IP address for". Your DNS Server says, "oh that's IP x.x.x.x", which is the external IP address. The browser will send the request to your IP, at which point, your router forwards it to the your server (with the internal IP address). The IP address of the web server is not part of the HTTP request/response, so it's not needed.

Requesting content from the web server

Your browser now knows that IP address, and sends a request to your iP. The request looks like:

User-Agent: [blah blah blah]
Cookie: [cookie info]

The response will look like

HTTP/1.0 200 OK
(new line)

Apache knows which host the request is for by domain name in the host/url, and pulls the content accordingly.

More documentation is available here:

Note: The older version of the HTTP protocol didn't support the Host header, so back then, if u wanted to set up virtual hosts on the same machine, it had to use multiple ip address and tie each ip address to a unique site. Some documentation out on the web may still reflect this. In general, tho, you don't have to worry about this as all browsers now support using the Host header

share|improve this answer
In "oh that's IP x.x.x.x", is that IP external or internal? – Thierry Lam Feb 24 '10 at 21:59
updated my answer to answer your question – Roy Rico Feb 24 '10 at 22:05
Explanation of the DNS request is wrong: the query to the root name servers (actually, all the queries) includes the full domain name. – bortzmeyer Mar 1 '10 at 8:15

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.