What is and how works a virtual host / custom domain / vanity hostnames


Virtual hosting is a http feature that allows:

In other term, this functionality permits to host several website on the same computer.

Implementation and Routing

Virtual host actually determine a host value to be used as ip name as a piece of routing information.

It's also possible to determine the requested name from the IP but most configurations use only name-based virtual hosts so the server doesn't need to worry about IP addresses.

When the user (browsers) makes requests, the web server application:

  • determines the host from the host header or request url
  • use this information to customize the response (such as serving a directory in place of another)

Host determination

The algorithm (as explained in section 5.2) is:

and if the host is not a valid host on the server, the response MUST be a 400 (Bad Request) error message.

Proxy (X-Forwarded-Host)

The implementation / configuration takes place

If you're server is running behind a proxy, the host header will be the hostname of the proxy, if the request uri is not qualified , you should therefore use the X-Forwarded-Host header to determine how to handle requests.

SSL and Certificate

Server certificate are part of the SSL protocol.

When using SSL, the SSL connection is established before the browser sends an HTTP request, the name of the requested server is then not known (and generally the default server’s certificate is served).

To resolve this problem and serve the appropriate certificate, several solutions can be used:

Solution Cons
Assign a separate IP address for every HTTPS server The oldest and most robust method but not easy to implement for dynamic custom domain
Lookup the name in the SSL Server Name Indication property
Use only one domain validated certificate with several name in the Subject Alternative Name (SubjectAltName) field (ie www.example.com and www.example.org) The SubjectAltName field length is limited
Use a wildcard certificate (for example, *.example.org)

Webhosting configuration


Your webhosting provider provide an interface to the configuration of your webserver.

Ovh Virtual Hosting Subdomain

Web Server / Proxy

If you host your server your self, you need to configure your webserver virtual host features.

Example: Apache - Virtual Host (Vhost)

Discover More
Card Puncher Data Processing
Apache - Virtual Host (Vhost)

virtual host configuration with Apache in the Apache Configuration file (apache/conf/httpd.conf), uncomment the line “Include conf/extra/httpd-vhosts.conf” Example: Below is an example...
Card Puncher Data Processing
OC4J - Setting Up Virtual Hosts

Setup multiple host on several domains using a single IP address. (ie ) This is a very basic example, it does not take into account using shared applications or event the use of .war or .ear files....
Server Name Indication (SNI)

Server_Name_Indication is an extension to the TLS computer networking protocol (not SSL) by which a client indicates which hostname it is attempting to connect to at the start of the handshaking process....
Map Of Internet 1973
What is a Hostname (or System's hostname)?

A hostname is a DNS name for a host (ie for the operating system) that is composed of: a label (generally called the short name) and a domain The hostname or computer name: is alogical name for...
What is the HTTP Host Header and how it is used?

This page explains to you what is the HTTP HOST header, how and where it's used.

Share this page:
Follow us:
Task Runner