Hosting 101 – What Are Virtual Hosts?

31st March, 2016 by

Virtual hosting is probably one of the most commonly encountered technologies in the hosting industry. It is the method through which a single web server is able to provide multiple different websites simultaneously. This is something that the industry has used for many years in order to provide shared web hosting which enables many customers to share a server’s resources to host their websites. The virtual hostname is used as a way of differentiating the configuration as being for a non-physical host, as opposed to the days prior to their existence where each website would require its own physical host.

Pretty much all modern web servers support virtual hosts as a configuration option, meaning that the chances are that your desired configuration is capable of working with the technology. There are also multiple ways to configure virtual hosts to work – they can use domain names, IP addresses or ports.

IP Based Virtual Hosting

IP based virtual hosting is one of the simpler methods to use and involves configuring the web server to respond to connections with different web sites dependent on the IP address on the server that the connection comes in on. When hosting multiple websites on a server using this method, then a unique IP needs to be used for each website. Until recently this was the only method by which you could use virtual hosting with SSL/TLS encryption on the connection to the server, although the creation of the Server Name Identification extension to TLS means that TLS encrypted connections can also now be used with name-based virtualhosts. Unfortunately, the requirement for an IP address per domain means that this method of virtual hosting can become expensive, as the IPv4 shortage has seen many providers increase their monthly price for additional server IP addresses, so tends not to be used as often.

Port-Based Virtual Hosting

Port-based virtual hosting is mostly similar to IP virtual hosting, only instead of using different IP addresses for each virtual host, the server would be configured to respond with different websites dependent on the port on the server that the incoming connection is using. This unfortunately has the downside that to connect to the server on a non-standard port (Port 80 for HTTP and Port 443 for HTTPS) the site visitor would need to append the port number that they want to connect to in the address bar of their browser, which as something extra for a visitor to remember to reach the site isn’t helpful for getting traffic to the site.

Name Based Virtual Hosts

Finally, name-based virtual hosts are probably the most common you will encounter. This enables the web server to differentiate between which website to serve based on the domain name used to connect. How this works is that when the browser is connecting to the server it sends a message to the server informing it of the domain name of the site being requested. This function requires a web browser that supports HTTP/1.1, but as this specification was released in 1997, pretty much all browsers you will encounter will support name-based virtual hosts. With the domain name sent to the server, it is then able to check its virtual host configuration and serve the correct website for the requested domain. The downside for this system is that if there is a problem with the domain name system for a specific domain being hosted on the server then there’s no way of accessing the website from the server.  A workaround for this is to have another virtual host that presents all the websites on the server, each as subdirectories for a website that the server responds to when only the IP address is used, though this only provides access to the website for those who know that this link exists. This configuration method can be helpful when initially setting up and testing websites prior to pointing domains at the server.

Hopefully, you now have a better idea of what virtual hosts are and how you may want to use them on your web server. In future articles, I’ll be looking at how they can be configured and used across a variety of web server software.

(Visited 96 times, 1 visits today)