I have a situation where I have a load balancer set up with Apache2 and mod-balancer that is going to load balance two Apache2 web servers. I'd like my load balancer to be able to serve multiple sites but currently every virtual host I create seems to serve the same site.
On the load balancer (lb1) I have the
default virtual host enabled so that when you browse to the load balancers IP address you see the standard Apache2 message.
The following is the virtual host layout that I use for all subsequent domains that the load balancer can serve (substitute
mydomain.com for the actual domain name of course):
<VirtualHost *> ServerName www.mydomain.com ServerAlias mydomain.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> <Proxy balancer://mydomain.com.cluster> BalancerMember http://web1.mycluster.com:80 route=web1 retry=5 BalancerMember http://web2.mycluster.com:80 route=web2 retry=5 ProxySet lbmethod=byrequests </Proxy> ProxyPass / balancer://mydomain.com.cluster/ stickysession=BALANCEID n$ ProxyPassReverse / http://web1.mycluster.com/ ProxyPassReverse / http://web2.mycluster.com/ </VirtualHost>
This is what a virtual host on the web server (
web2) end looks like. Both web servers have the same virtual hosts enabled. The only difference between the virtual hosts is the reference to either
web2 respectively (I show the virtual host of
<VirtualHost *> ServerName www.mydomain.com ServerAlias mydomain.com RewriteEngine On RewriteRule .* - [CO=BALANCEID:balancer.web1:.mydomain.com] DocumentRoot /mnt/share/mydomain.com/www/public_html <Directory /> Order allow,deny Allow from all </Directory> </VirtualHost>
This seems to work for
mydomain.com. If I create another virtual host with the same layout e.g. for
myotherdomain.com then browsing to
myotherdomain.com will actually serve
What I'm I doing wrong?