Software virtual hosting - technical details

The background to the problem

Traditionally, if a single computer is required to host several different web sites, a technique known as IP address aliasing is used: only one network card is used, but it has several IP addresses, with each web server set to listen on a different address. This is sometimes called hardware virtual hosting or IP-based virtual hosting.

However, IP addresses are running out. Fast. A lot of ISPs and registration agencies are now not allocating whole Class Cs to companies at all, but only giving them the minimum number of addresses they actually need.

The solution!

More recent browsers offer an alternative method of hosting several web sites on one computer. As an optional part of the HTTP protocol, the browser sends the host part of the URL (the name of the machine), as well as the 'local' filename part. This is technically part of the HTTP/1.1 specification, but one that has already found almost universal acceptance.

Certain web servers check this extra information, and can use it to decide between several sets of web pages, even if there is only one IP address being used. This is sometimes called software virtual hosting, or name-based virtual hosting, and is more efficient use of a diminishing resource, albeit at the expense of compatibility with some (mostly older) browsers. Increasingly, web-hosting companies and ISPs are only offering software virtual hosting, or charge a premium for hardware virtual hosting.

The gory details...

All a browser has to do is add an extra header to the HTTP request, along with User-Agent, If-Modified-Since and any others it normally sends. The syntax is
eg. when requesting the URL, the browser should send:
     GET /index.html HTTP/1.0
     User-Agent: Mozilla/3.0 (compatible)
and so on.

There is no disadvantage in a browser sending this information, since computers which use traditional hardware virtual hosting will simply ignore it. The advantage though is that the browser can then retrieve pages from computers which use software virtual hosting. As IP addresses continue to run out, the Net is likely to see more and more of such web sites. At least until IPv6 comes in, but that's a different story!