As from what I understand the DNS link the domain name with the IP address of the server the website is stored on, does that mean each server can only hold one website?
First, you need to understand that there are a number of distinct concepts here.
- Web site, a group of web pages that form a coherent whole.
- IP address, a numerical address (32-bit for IPv4, 128 bit for IPv6) used by the internet protocol as the source or destination for traffic.
- Server, a machine whose job is to serve requests from clients.
- Hostname, a name used to identify a machine in DNS (e.g. "www.example.com" or "en.wikipedia.org")
There is not a one-to-one relationship between any of these things. One server can have multiple IP addresses; multiple hostnames can point at one IP address; one host name can point at multiple IP addresses. Multiple websites can be under the same hostname. One website can be spread across multiple hostnames.
If they don't, how does calling the server's IP address know which website I want if there are many on the same server?
In the old days (HTTP 1.0 and before) each hostname that the server wanted to handle differently had to have its own IP address. This was rather wasteful.
HTTP 1.1 added the Host
"header as a mandatory field in the HTTP request (IIRC some vendors had previously supported this as an extension). This told the server which hostname had been requested and hence allowed it to serve different content for different hostnames on the same IP address. Support for HTTP 1.1 in clients is now ubiquitous.
Unfortunately, SSL (later TLS) added a wrinkle. Establishing a SSL/TLS session requires the server to present a certificate to the client that covers the requested hostname, but the HTTP request doesn't arrive until after the SSL/TLS session is established.
It is possible to have one certificate cover multiple hostnames through the use of the SubjectAltName
field or the use of wildcards in the CommonName
field. However, this poses administrative challenges, especially if the hostnames involved are under domains with different ownership.
So TLS introduced the "server name indication" (SNI) extension. With this extension, the client sends the requested hostname to the server during the TLS handshake procedure. The server can then present the appropriate certificate. Unfortunately, while current versions of all major SSL/TLS implementations support SNI, it has taken a long time for older versions to fall out of use.
13
Wikipedia has a good introduction to Shared Web Hosting. If you enter http://<IP_ADDR>/ in your browser, the HTTP request won't have a domain within the
– Jedi – 2016-06-18T03:30:14.703Host:
header. In case of shared hosting, the web server can be configured by the provider to handle this in different ways (e.g. have a default, redirect to provider etc.).I have clicked links that break with messages like "this server has never/currently does not host the website you are looking for". – Jesvin Jose – 2016-06-18T17:52:16.000
1In case you're looking far a way to run multiple applications on a single server-- say you have two apps MyApp and YourApp on ports 8001 and 8002 respectively. You can have two load balancers or application proxies at: myapp.com and yourapp.com. Have them receive requests at the default ports (80/443) and forward it to the actual server(s) at ports 8001 and 8002 respectively. – rohithpr – 2016-06-18T19:30:58.960
6
Great question. Every website used to need its own IP address (a server can have more than one IP address). The Host header in HTTP/1.1 was introduced to get around the exact problem you describe. See "Internet address conservation" in http://www8.org/w8-papers/5c-protocols/key/key.html
– A E – 2016-06-18T22:15:03.7806If http 1.1 didn't have the host header, ipv6 would be implemented by now ;-) :-( – Lenne – 2016-06-20T08:43:32.617
Not only do you get many websites per server, with some technologies (eg Apache vhost) an infinite number of websites can be called into existence at the moment someone asks for one. – pjc50 – 2016-06-20T10:12:43.120
OP, also keep in mind that each physical server can have multiple virtual servers running on it. Virtualization offers a lot of helpful IT admin abilities. – Bulrush – 2016-06-22T11:19:12.520