1

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

0

4 Answers 4

1

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.

0

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.

2
  • I'm using two virtual machines, that means two different Apache instances on different machines.
    – Gutsav
    Jan 30, 2010 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? Feb 1, 2010 at 3:16
0

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

0

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)

Disadantages:

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 http://www.gtwcmt.co.uk/virtual-host-creation-in-apache-windows/

You must log in to answer this question.