How does multiple domains pointing to one IP address work

Because HTTP request sent from browsers includes the host name. The server is able to identify it and serve the respective content.

In our world we have very limited IPV4 addresses but more websites. A web hosting company usually serves over hundreds of websites from the same server (same IP).


You can host as many sites as you want from one Server (one IP). All you need is to is to:

  1. Point the A record of the websites (from the DNS settings of the NameServers of the respective websites) that you want to host to the IP of the Server
  2. Create Virtual hosts on the Server.

If you're using an IIS server, you can check out https://support.microsoft.com/en-us/kb/816576

There are different tutorials based on which server you're using. Just search for virtual hosts and the server and you should be good to go!


Your server that is listening at that address can decide what to serve up.

if request.host==host1 then
  //Serve site 1
else
...

This was just pseudocode, but it can probably be done with most server side code frameworks

Tags:

Dns

Domains