[H-GEN] Apache and Virtual Hosts

Martin Pool martinp at mincom.com
Tue Dec 14 19:46:25 EST 1999


[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics.  Please observe the list's charter.          ]

> Well I could be wrong (I'm reasonably new at Apache configuration), but if
> both your servers have the same IP (which according to nslookup they do),
> how will your server tell which one is being accessed?  

> Surely you need
> two different IP addresses so that Apache can work out which set of
> pages to serve.

No, you don't.  As Bruce said, this is "name-based virtual hosting".  It
saves you being larted by ip-space administrators because it doesn't
waste an IP address for every trendy-little-e-company.com.

Crib notes for those who didn't read the RFC:

  user requests http://fire.humbug.org.au/

  user agent resolves fire to 130.102.32.23

  (assume there is no proxy)

  ua opens a tcp socket to 130.102.32.23:80

  ua writes a request

    GET / HTTP/1.1
    Host: fire.humbug.org.au
    User-agent: foo/1.0
    ...

So you see the web server gets to see what domain is being requested as
well as the local socket address.

The host header is (IIRC) only specified in 1.1, but is widely
implemented in 1.0 software because it's so useful.  In practice, there
is no reason to use IP-based virtual hosts today.

> Eeek! I'm using Outlook 2k (shoot me now, I deserve it) and I don't get the

Duh.  Don't do that then.

> Virtual hosts works by detecting if you are looking at
> http://stevens.psy.uq.edu.au or http://fire.humbug.org.au - and sends you
> the pages accordingly. For the life of me I can't remember what happens when
> you try to go to http://130.102.32.23 however.

It uses the default vhost for that address.  If you expect to support
ancient clients then you can use that to present a menu of available
domains.  You can then map the domains into subdirectories using a
directive whose name I forget. (rtfm)  http://130.102.32.23/fire/

-- 
Martin

Microsoft has a serious Year 2000 problem.  We're it.

--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list