1

I would like to know how to access websites by IP address in a server that hosts more than one web application?

Currently I can get the IP address of the server, but it points to one site by default. Is there a prefix or suffix that I can add to the IP address to get a particular website in the server?

Eg: I would like to access by IP address:

  1. http://mysubdomain1.domain.com
  2. http://mysubdomain2.domain.com
  3. http://mysubdomain3.domain.com

The server hosts many ruby on rails web apps via nginx and unicorn.

Thanks in advance.

Uri Agassi
  • 36,848
  • 14
  • 76
  • 93
ipegasus
  • 14,796
  • 9
  • 52
  • 76
  • What the reason to do so? – Alexey Ten May 10 '14 at 17:15
  • This question appears to belong on another site in the Stack Exchange network because its not about programming. Perhaps [Super User](https://www.superuser.com/) or [Server Fault](http://serverfault.com/). – jww May 11 '14 at 11:32

2 Answers2

2

Assuming that the server has one public ip address, and been set up to serve virtual hosts, you can do that like this:

curl -H "Host: subdomain.domain.com" IPADDRESS

1

I don't think your question has enough information to be answered accurately not in depth.

Here are some thoughts.

There are different ways in which websites can be hosted. Via IP, aliases, named virtual hosts, etc.

There's a good chance that the server that's hosting those websites uses named based virtual hosts https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3

That is, one ip points to multiple servers. In that case, the only way you can get to it, is by knowing the domain name.

Here's more or less how it would work

  1. User requests http://mysubdomain1.domain.com
  2. Server with single ip has an entry for that subdomain1 and forwards requests to it.
lsaffie
  • 1,764
  • 1
  • 17
  • 22