Apache Name-based virtual hosts

Name-based virtual hosts allow a web server to host multiple domain names (www.daemons.net, mail.daemons.net, blatch.daemons.net) from one IP address. This allows a web hosting infrastructure to conserve IP address space, and simplify namespace management.

Apache name-based virtual hosts are configured with the “NameVirtualHost” and “VirtualHost” directives, and rely on the HTTP “Host:” header attribute. This attribute is required in HTTP 1.1, and should be present with every request. The following example grabs /index.html using the HTTP/1.1 protocol:

$ telnet www.daemons.net 80
Trying 66.36.244.105...
Connected to www.daemons.net.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.daemons.net

HTTP/1.1 200 OK
Date: Thu, 24 Feb 2005 16:33:23 GMT
Server: Apache/2.0.52
Last-Modified: Sun, 20 Jun 2004 14:39:21 GMT
ETag: "d54a2-912-c108d840"
Accept-Ranges: bytes
Content-Length: 2322
Content-Type: text/html

[ ... ]

Based on this output, it looks like my friend Clay needs to obscure his “Server:” header. Server identification is controlled with the “ServerTokens” directives.

Leave a Reply

Your email address will not be published. Required fields are marked *