views:

460

answers:

6

Hi,

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.

+10  A: 

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.

alamar
+1  A: 

It's a configuration of the web server. The web server will look at the host name requested, and show the web site configured for that host name.

Philippe Leybaert
+2  A: 

This is called virtual hosting. It's where the webserver (Apache etc) serves different content based on the hostname being used in the requests.

Cogsy
+1  A: 

A web server can be made to react differently depending on which hostname was used to come to the IP address. This is known as Name-based (as opposed to IP-based) virtual hosting. The Name-based vs. IP-based Virtual Hosts section of Apache's Name-based Virtual Host Support document explains in more detail.

lance
A: 

Two parts:

  1. The http request to the server includes the host name, so the http service on the server can respond differently depending on the web site you're trying to connect to. (I just learned this last night).
  2. The redirect is occuring based on host name, not IP address. If you don't use a host name, the server doesn't know how to redirect you.
Mark Ransom
A: 

The short version is: they are not the same request.

The most likely answer is what was provided by alamar (which I up-voted too), but also, there are a lot of possible factors your did not check:

1- The two url's result in different HTTP requests.

This is a result of the way HTTP works. At the network level, you are assuming the same connection is made (to the hostname's HTTP port), which is true. However, the server returns content based on other application-level (HTTP) variables.

2- The connection was not actually made to the IP address. There are many mechanisms that provide network indirection. The most important are: proxy configuration and DNS caching. In either case, using netstat to confirm the connection is the best course of action.

3- A third party is modifying the content.

This could be for both good or bad reasons. You could have security software, a NAT from a WiFi hotspot, etc.

benc