Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I run two virtual web servers (both running apache2 on debian). I have just one external IP, but two domains, and I want a domain going to each of the servers.

I've understood that I need a Reverse Proxy, and I enabled both the mod_proxy and the mod_proxy_http modules on the "primary server". Do I need to enable anything on the "secondary server"?

I also understood that I need to write some things in a virtual host file, but what? On the primary server, I have a virtual host file for one of the domains, and some for subdomains. I want domain1.tld to go to the primary server (port 80 is forwarded to it, so that works) and domain2.tld to go to the other server (internal ip 192.168.0.x). No ports needs to be forwarded to it, right? So, what to add and in which virtual host file? Or a new one? Other questions suggest adding ProxyPass and ProxyPassReverse, but I'm lost anyway, and I just don't understand the apache documentation.

Thanks in advance

share|improve this question

migrated from Jan 30 '10 at 2:21

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

You might want to look at using HAProxy, which does this sort of thing very well.

In a nutshell, you'd create a third VM which runs HAProxy and has your IP address. Your HAProxy configuration will determine to which Apache instance the request is sent on the back end.

Take a look at the site and if you want to give it a try, then you can ask more questions.

share|improve this answer

Two domains on a single Apache Instance (eg one physical machine) with a single IP address is very simple and is known as Name Based Virtual Hosts.

The Apache manual covers it very well and even you should be able to make some sense out of this page:

I'm slightly baffled by what you're trying to do with mod-proxy. It seems far too complicated and for no real reason. Hope this helps.

share|improve this answer
I'm using two virtual machines, that means two different Apache instances on different machines. – Gutsav Jan 30 '10 at 12:31
So you would need a third (virtual) machine to have the real world IP address, and then serve the content of the other two websites via a "private network" connection to them? – BuildTheRobots Feb 1 '10 at 3:16

Sounds a lot like this, though not having had to do this yet, i'm not sure

share|improve this answer

You can run more than one server and one domain on one server.

Alias or Vhost will accept different domains on one prime server as the Vhost config file sets domain name and server name, thus a single server can run two domains on one server and IP. Benefits: One server runs multi domains Limit resources (only using one server to serve sites)


If you already have a heavy server usage from a prime domain adding more servers will not help.

Other solution: You need a load balancer, this goes infront of the servers routing to forward domains to each IP behind a firewall or not on a single IP address to local ip's.

Here is an article I wrote to set up hosting of different domains

share|improve this answer

Your Answer


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