Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I wanted to gather peoples thoughts on the following situation:

Two Apache servers, A1 and A2.

Both servers are behind a router that can forward port 80 to only one ip, so how do you manage two servers hosting different domains on one IP?

I've looked into mod_proxy with little success, and wondered if there was any "DNS port forwarding" feature you can install to manage packets.

For example IP address is (fake don't try it :p).

A1 hosts foo.com A2 hosts bar.com

port 80 forwarded to A1. A1 realises it's a request for bar.com, so acts as a proxy between A2 and the router.

I hope this makes sense, and any help would be appreciated!

share|improve this question

migrated from stackoverflow.com Jun 18 '11 at 1:17

This question came from our site for professional and enthusiast programmers.

If you're using two Apache Servers, why not just cut it down to one, and host both domains on the same server? It's actually pretty easy, unless there's a necessary reason for you to use two servers. –  Jebego Jun 18 '11 at 0:13
Run a loadbalancer/reverse proxy on a box on 80. You can use mod_proxy, or maybe nginx. Forward traffic from the proxy to your two apache boxes as appropriate. –  Frank Farmer Jun 18 '11 at 0:14
Can i ask why this got a downvote? –  Abe Petrillo Dec 2 '11 at 14:32

1 Answer 1

up vote 5 down vote accepted

technically it's not possibly unless your router has a built in reverse proxy or some layer 7 routing which none that I know of do. If you want to really do it this way and want to make it scalable, then you will need to have a reverse proxy which has maps of site names and where to proxy it to.

<VirtualHost *:80>
  ServerName www.domain-a1.com
  ProxyRequests Off
  ProxyPass http://servera1/
  ProxyPassReverse http://servera1/

<VirtualHost *:80>
  ServerName www.domain-a2.com
  ProxyRequests Off
  ProxyPass http://servera2/
  ProxyPassReverse http://servera2/

This will not work for SSL sites as the SSL negotiations happen before knowing which site it's for, but then switch SSL certs to pass to them (chicken and the egg), etc.

share|improve this answer
Much appreciated. Will test this out :) –  Abe Petrillo Jun 18 '11 at 7:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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