Wrox Home  
Search P2P Archive for: Go

  Return to Index  

apache_server thread: Virtual Hosting - How does it really work????


Message #1 by "Tom Fielder" <tomfielder@h...> on Mon, 10 Mar 2003 21:52:37
I'm setting up a webserver that will be used to host multiple websites 
using virtual hosting.

I think I've configured Apache correctly, but I'm still a bit confused to 
how it's actually going to work (I haven't been able to test it yet as I 
don't have the domains...).

For example...

Say I have 3 websites that I'm vitually hosting, www.a.com, www.b.com and 
www.c.com.

Whenever a user types in ANY of the above into their browser, the DNS 
will direct them all to the same IP address (My network's external static 
IP address). As it is an http request, my router will forward the user to 
my webserver, but how does it know which site to pick?!?!?!?

Sure, my webserver has multiple internal IP addresses (same network 
card), for example:

In the apache conf file:
www.a.com = 192.168.0.10
www.b.com = 192.168.0.11
www.c.com = 192.168.0.12

This is the code I'm using (exactly the same for b and c but with the 
obvious changes).

<VirtualHost 192.168.0.10>
  ServerName www.a.com
  ServerAdmin webmaster@s...
  DocumentRoot "E:/Program Files/Apache Group/Apache2/virtual/servera/"
  DirectoryIndex index.html index.php index.html.var
  ErrorLog "E:/Program Files/Apache 
Group/Apache2/virtual/servera/logs/servera-error_log.log"
  CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

All I can think of as a solution to my question is that somewhere along 
the way, the browser remembers what the user typed into the browser in 
the first place, e.g. www.a.com and looks for a match in ALL of the 
virtual host ServerName's for a match.

Probably totally wrong, and I know you're just cringing at my 
stupidity... Please, somebody, help me!

Thanks,

Tom

  Return to Index