# Two servers, two domains, one ip. mod_proxy beginner

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.

-

## migrated from stackoverflow.comJan 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.

-

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: http://httpd.apache.org/docs/2.0/vhosts/name-based.html.

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.

-
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

-

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)