23

Today I bought a shared hosting package. Then I added an index.html to it via FTP. When I enter my given IP address in Chrome, I'm always seeing Plesk's default page, instead of my index.html. But then I edited my Windows's hosts file and entered a domain name next to the IP. When I entered that domain name in Chrome, I saw my index.html file correctly.

So my question is, why can't I see my index.html via requesting directly with my IP address?

  • 2
    Please ask your hosting provider for an IPv6 address. There's no need for shared addresses with IPv6. – Martin Schröder Jan 26 at 22:41
39

I think I found my answer.

So, the thing is, because I bought a shared hosting package, they also gave me a shared IP. My guess is, this IP has many websites next to mine and they're all accessible with this same shared IP address.

The trick is the HTTP GET request's Host header!

When I entered the shared IP directly in the address bar, the Host header is the same as the shared IP address. So the host doesn't know which shared website to display as a response.

And when I edited Windows's Hosts file and then examined the HTTP GET request, I saw that the Host header is set to my domain name, even though I requested the same shared IP! So this time, the host knows which website that this request belongs to!

| improve this answer | |
  • 10
    This is exactly correct. I'm glad you were able to figure it out on your own and post an answer here. – Stephen Ostermiller Jan 25 at 18:07
  • 4
    Good job self-answering. And welcome to StackExchange! – Harper - Reinstate Monica Jan 26 at 7:03
  • 8
    I'd like to add that this form of hosting is 100% normal. In fact, I always configure my sites to only serve the content on the correct hostname even if that site is alone on that IP. – marcelm Jan 26 at 13:17
  • Plesk and other panels/hosts will have preview URLs such as http://10.10.10.1:8443/sitepreview/http/www.example.com/ and in the past http://10.10.10.1/~www.example.com or something similar. – AbraCadaver Jan 27 at 19:02
  • You might want to take that entry out of your hosts file to avoid problems in the future. You can end up pulling your hair out with a "manual" entry in your hosts file that refuses to resolve correctly after a IP change, etc. – Greg Nickoloff Jan 28 at 17:56
4

Yes, it is very unusual to get a dedicated website IP address these days unless you specifically ask for one, and usually at a cost.

Typically the hosts node apache/nginx server will run a default config page on the public IP address of the node and create "vhosts" for each website they need to run (generally managed by something like cpanel).

The webserver responds appropriately to the request it receives, so if the request is jazzhands.com it will check if it hosts that site and then serve it up.

You'll need to create an A record in your DNS zone and point it to the public IP address of the node to make this work for other users.

Sometimes hosts will try and convince you to just set your domains Nameservers to their infrastructure "to make it easier" but I generally advise against this as the name servers provided by reputable domain registrars tend to be more reliable and remain much more under your control.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.