Virtual hosting

From ArticleWorld


Virtual hosting is a technique used by web servers to host more than one domain name on the same computer and IP address. This technique is often used by shared web hosting services.

Name-based hosting

Name-based virtual hosting uses multiple host names for the same IP address. As most web browsers support HTTP/1.1, browsers that connect to a webserver send the address typed in their address bar. This can be used by the webserver to determine exactly what web site and what web page the user wants. By allowing the web server to decide exactly what to deliver, DNS services play a less important role, thus allowing more sites to resolve to the same address.

For example, the addresses www.foo.com and www.bar.com could resolve to the same IP. When the web server receives the request for the index pages, it will provide the HTML file located at /www/foo/index.html or /www/bar/index.html (purely fictional example) based on the address it receives.

This method's greatest problem is that it is not DNS failure-safe. If the user knows the IP of the website he is trying to access, and tries to access it directly with the IP when his DNS server is not functioning, there will be no way for the web server to know what to provide. The workaround would be for the user to place an entry in their hosts file, so that the name can still be resolved, but it is still not too helpful.

Another problem is that it is impossible to host more secure websites using SSL. The SSL handshake has to be done before the hostname is sent to the server, so there is no way for the server to know what key to use for which website. Although this can be solved by running multiple web servers bound to different ports, or by using IP aliasing, it is still a major technical difficulty.

IP-based hosting

The other possibility is to have several sites point to the same unique IP address. The webserver has more physical interfaces, and uses several virtual network interfaces bound to the same physical interface. In order to decide what page to provide, the webserver obtains the address that the TCP connection asked for, therefore not involving the client in the process.