[plug] Apache virtual hosts

Anthony J. Breeds-Taurima tony at cantech.net.au
Mon Jan 15 15:12:55 WST 2001


On Mon, 15 Jan 2001, Kevin Shackleton wrote:

> I have Apache on NT4 at work, and I've just set up a virtual host in the conf
> file.  Works a treat, except that now the "real" host has vanished.
>
> I suppose that's because, in the client's hosts file, I've pointed to the virtual
> host to the same IP address as the server, and both are using port 80, so there's
> no difference between client calls to the server or to the virtual host.

It should work the same under both NT and U*ix ... I have done.

NameVirtualHost 203.26.6.29

<VirtualHost _default_:*>
DocumentRoot /home
</VirtualHost>

<VirtualHost 203.26.6.29>
ServerName www.somewhere.com.au
DocumentRoot /home/httpd/somewhere
ErrorLog logs/somewhere-error_log
TransferLog logs/somewhere-access_log
</VirtualHost>


Then both web sites appear on the same IP.

You can get lots of info at:
http://httpd.apache.org/docs/vhosts/index.html

> Have I overlooked something that would distinguish the two?

The Host header is the thing that does it.

from a telnet on the same host you can do:

telnet localhost 80
GET / HTTP/1.0<enter>
Host: www.host1.com<enter><enter>

You should see the html for the index page of site1

telnet localhost 80
GET / HTTP/1.0<enter>
Host: www.host2.com<enter><enter>

You should see the html for the index page of site2


Yours Tony.

/*
 * "The significant problems we face cannot be solved at the
 * same level of thinking we were at when we created them."
 * --Albert Einstein
 */




More information about the plug mailing list