1

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 87.166.55.44 (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!

3
  • 1
    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, 2011 at 0:13
  • 1
    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. Jun 18, 2011 at 0:14
  • Can i ask why this got a downvote? Dec 2, 2011 at 14:32

1 Answer 1

6

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>

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

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.

2
  • Much appreciated. Will test this out :) Jun 18, 2011 at 7:41
  • For the case of SSL, what you can do is use SSL up to the reverse proxy, and make it serve the SSL certificates. Then let it forward to your other servers over plain HTTP, but in a protected internal network only.
    – tanius
    Jan 7, 2019 at 1:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .