Keep Server Online
  
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
  
or
  
 
  
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
  
Thank You! Steffen
  
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
 |    |   
 | 
     Topic: Load Balance Multiple Domains? | 
 |   
| Author | 
  | 
 
ShakeSpear
 
 
  Joined: 01 Apr 2015 Posts: 1 Location: USA
  | 
 Posted: Thu 02 Apr '15 2:24    Post subject: Load Balance Multiple Domains? | 
     | 
 
  | 
 
Hey guys, I am completely new to apache and I had the load balancer set up for a single domain that was working perfectly fine, but when it came to multiple domains i couldn't, for the life of me, figure out what to do.
 
 
There is example.com sub.example.com and otherexample.com 
 
 
I had a single node set up for this but I want to experiment with the balancer. I have scratched Google and I only found broken info which couldn't explain much to me. Here are my domains
 
 
<VirtualHost *:80>
 
DocumentRoot "/var/www/domain.com"
 
ServerName domain.com
 
</VirtualHost>
 
 
<VirtualHost *:80>
 
DocumentRoot "/var/www/seconddomains/"
 
ServerName liquidapps.co.uk
 
</VirtualHost>
 
 
<VirtualHost *:80>
 
DocumentRoot "/var/www/sub.domain.com"
 
ServerName sub.domain.com
 
</VirtualHost>
 
 
Would anyone be kind enough to help me with an example configuration of the default file.
 
 
Thanks! | 
 
  | 
 
| Back to top | 
 | 
 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7442 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Thu 02 Apr '15 10:31    Post subject:  | 
     | 
 
  | 
 
As much as simple I can get it
 
 
 	  | Code: | 	 		  
 
<Proxy balancer://myclusterone>
 
   BalancerMember http://192.168.1.50:80
 
   BalancerMember http://192.168.1.51:80
 
</Proxy>
 
 
 
<VirtualHost *:80>
 
   DocumentRoot "/var/www/example.com"
 
   ServerName example.com
 
   ProxyPass / balancer://myclusterone
 
   ProxyPassReverse / balancer://myclusterone
 
</VirtualHost> 
 
 
<Proxy balancer://myclustertwo>
 
   BalancerMember http://192.168.1.52:80
 
   BalancerMember http://192.168.1.53:80
 
</Proxy>
 
 
<VirtualHost *:80>
 
   DocumentRoot "/var/www/sub1.example.com"
 
   ServerName sub1.example.com
 
   ProxyPass / balancer://myclustertwo
 
   ProxyPassReverse / balancer://myclustertwo
 
</VirtualHost> 
 
 
 
<Proxy balancer://myclusterthree>
 
   BalancerMember http://192.168.1.54:80
 
   BalancerMember http://192.168.1.55:80
 
   BalancerMember http://192.168.1.56:80
 
   BalancerMember http://192.168.1.57:80
 
</Proxy>
 
 
<VirtualHost *:80>
 
   DocumentRoot "/var/www/sub2.example.com"
 
   ServerName sub2.example.com
 
   ProxyPass / balancer://myclusterthree
 
   ProxyPassReverse / balancer://myclusterthree
 
</VirtualHost> 
 
 | 	  
 
 
An example for the factor of balancing
 
 
 	  | Code: | 	 		  
 
    ProxyRequests Off
 
    ProxyVia Off
 
    ProxyPreserveHost On
 
    ProxyErrorOverride On
 
    ProxyTimeout 30
 
    <Proxy balancer://pool1>
 
      BalancerMember http://server1:8080 min=10 max=50 loadfactor=2
 
      BalancerMember http://server2:8080 min=5 max=25 loadfactor=1
 
    </Proxy>
 
    ProxyPass /shop balancer://pool1 lbmethod=byrequests nofailover=Off maxattempts=3 stickysession=PHPSESSIONID
 
 | 	  
 
 
See also http://httpd.apache.org/docs/current/en/mod/mod_proxy.html#proxypass the section BalancerMember parameters | 
 
  | 
 
| Back to top | 
 | 
 
 
 
 
 | 
 
 
 |  
 
 |  
  |   
 |