How to access a website by IP address in a server that hosts many websites?

不想你离开。 提交于 2019-12-24 16:43:18

问题


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.


回答1:


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




回答2:


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.


来源:https://stackoverflow.com/questions/23576360/how-to-access-a-website-by-ip-address-in-a-server-that-hosts-many-websites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!