Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigating to IP address shows different page than navigating to hostname?

I'm looking at a web site we'll call www.example.com . A quick traceroute www.example.com shows that its IP address is 208.76.xx.xxx .

When I browse to "www.example.com" in Firefox, I am shown the web site (a login page). However, when I browse to 208.76.xx.xxx , I am shown a default "Welcome to cPanel!" web page.

Here is some more information:

  1. When I navigate to "www.example.com" or "http://www.example.com" in Firefox I am redirected to "http://example.com" where I see the normal web page.
  2. curl -L www.example.com returns the web site, while curl -L 208.76.xx.xxx returns the "Welcome to cPanel!" page.
  3. Looking at just the headers: curl -LI www.example.com shows that I am redirected to the site's login page (as expected), while curl -LI 208.76.xx.xxx does not have a redirect.
  4. 208.76.xx.xxx does not appear in my hosts file.
  5. I am using OpenDNS.

Can someone please explain why navigating to the site's domain name shows a completely different page than navigating to the site's IP address?

Thanks for your help, and feel free to ask questions/suggest tests for me to run.

like image 724
tba Avatar asked Dec 05 '22 06:12

tba


1 Answers

It is called virtual hosting.

One web server (and IP address) can server thousands of sites, with different Host: field in HTTP requests.

You ask browser for example.org; browser tells the server

GET / HTTP/1.1
Host: example.org
Connection: close

Webserver looks if it can serve example.org, if it can, it would serve the root page for this specific site.

Proxies also work that way: you browser sends every HTTP request to the proxy, giving Host:, proxy connects to that host, asks for a page and gives it back, cached.

like image 56
alamar Avatar answered Apr 26 '23 09:04

alamar