I have always been confused by the idea that multiple websites sharing the same IP address. I mean if there is a webserver out there that has an IP address. I can simply key in this IP address with the right port such as 80 and the destination gateway knows which server to forward this incoming request. This case, port 80 is the webserver and the website is served out to the client.
However, I do not understand how two websites can be hosted on the webserver and one IP address. Let's say the two websites with names of abc.com and xyz.com are hosted on the same webserver with one IP address. The DNS server that I use such as one from my ISP can resolve the names with the IP adress just fine, pointing my web browser to the correct webserver, but my confusion is how the webserver know which website to serve out?
I always thought that the only way to differentiate between different websites on the same webserver is their respective port numbers. In other words, if the incoming request is on port 80, it's abc.com and if it is port 81 it is xyz.com. Obviously, I am not putting in xyz.com:81 on my web browser so it uses port 80 by default. Then why do I get the actual xyz.com website in return and not abc.com?