Load balancing / Load Balancing Configuration Examples |
Apache HTTP Server versions 1.3.x and 2.0.x provide load balancing by using mod_rewrite Apache module.
Refer to the following:
All configurations examples explained here work on both Apache version 1.3.x and 2.0.x
# Apache configuration file <IfModule mod_rewrite.c> RewriteEngine on RewriteMap servers rnd:hosts.txt RewriteRule ^/(.*) http://${servers:host}/$1 [P,L] </IfModule>
host GAS1.corporate.com|GAS2.corporate.com
For example, the http://localhost/ws/r/echo URL will be rewritten to http://GAS1.corporate.com/ws/r/echo, assuming that the GAS1.corporate.com server has been chosen.
# Apache configuration file <IfModule mod_rewrite.c> RewriteEngine on RewriteMap servers rnd:vdirs.txt RewriteRule ^/gas/(.*) /${servers:vdir}/$1 RewriteRule ^/GAS1/(.*) http://GAS1.corporate.com/GAS1/$1 [P,L] RewriteRule ^/GAS2/(.*) http://GAS2.corporate.com/GAS2/$1 [P,L] </IfModule>
vdir GAS1|GAS2
For example, the http://localhost/gas/wa/r/gwc-demo URL will be rewritten to http://localhost/GAS2/wa/r/gwc-demo, assuming that the servers:vdir variable contains GAS2 at this time, then will be rewritten to http://GAS2.corporate.com/GAS2/wa/r/gwc-demo. Likewise, the http://localhost/GAS2/wa/sua/93837374/1 URL will be rewritten to http://GAS2.corporate.com/GAS2/wa/sua/93837374/1.