How do I host multiple physical Web servers behind a single IP address?

14

10

I am running multiple web servers in my house, each of which is plugged into my router.

Server A Server B Server C

I currently can only use one server since my IP (xx.xxx.xx.xx) port 80 is pointing towards server A. However some domains point to server A, some to B, etc.

With my one IP address, how do I point to each server? For example my A(host) records all point to just my IP address.

Sorry if I sound confusing. Let me know if I am not being clear.

Each server is running Ubuntu Server 12.04.02 and is using Apache (if that helps). My router is also a Netgear and my ISP is Time Warner Cable.

Stephen Cioffi

Posted 2013-06-22T20:29:50.503

Reputation: 321

possible duplicate of Multiple web servers behind a single firewall

– kobaltz – 2013-06-22T20:38:02.093

@kobaltz Not exactly since these are different servers, not virtual hosts. These are 3 physical servers – Stephen Cioffi – 2013-06-22T21:42:03.243

My answer within the question is still the same thing where you would have a reverse proxy server that would be what is first hit after the router. From there, it would push the data to one of the three servers. You can even do this from within the router if you use something like OpenWRT. – kobaltz – 2013-06-22T23:52:53.143

I'm currently using the explanation in my answer of the other question. I have a Virtual Machine server that had a VM for the gateway, and then 20 nodes. Depending on the subdomain and the domain name, it pushes the data to one of the 20 servers. – kobaltz – 2013-06-22T23:54:25.587

Answers

9

Web sites will be recognized through the Host: header sent from the browser. But since your router isn't capable of HTTP demangling used by virtual hosting, you will need to choose one server as "endpoint" (and tell your router that address as Virtual Server / DMZ).

Then, you either configure that one machine as webserver for its domains and proxy for the others (e.g. using Apache reverse proxy), or (maybe better) you install a proxy on that one machine, and use it to multiplex requests to the other servers. Some domains might even be hosted on the same machine. nginx is suited for this kind of work, but you can also use other software (e.g. pound).

I think the second solution is better because you do not need to fiddle with web servers' configurations at all: one proxy does the proxying and several web servers do the web serving. If you need to add servers or move virtual hosts around, this architecture is easier to maintain.

                                    +-- virtual hosts 1..9 -- server B
                                    |
router ----- machine A (nginx?) ----+-- virtual hosts 10..23- server C
                                    |
                                    +-- virtual hosts 24..99- server D

The added latency due to the request being decoded twice (once by the proxy, once by its intended recipient) is negligible, and more than offset by the acceleration provided by the proxying itself.

LSerni

Posted 2013-06-22T20:29:50.503

Reputation: 7 306

If I create a VM guest as a proxy, what is the best OS to use and what hardware resources should I allocate? You mention setting this proxy on the DMZ... is this necessary? Can't I port forward just the ports I want open so that there's still some layer of protection through the router's firewall and NAT? – Reece – 2016-03-10T01:08:58.187

Resources for the proxy aren't a problem, it will be heavily network-bound. As for the OS, I'd say an Unix for sure, Linux or BSD depending on what you're most comfortable with. There are also ready-made appliances for several virtualization solutions (vmware, virtualbox, xen, etc.). And yes, you can definitely port forward only those ports you need. – LSerni – 2016-05-10T06:08:05.990