How do I host multiple physical Web servers behind a single IP address?
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.