Mar 18, 2009 10
Sticky load balance with Apache HTTPD 2.2
Apache HTTPD 2.2 includes some interesting features for making a basic load balancer.
This configuration makes a sticky loadbalancer with 3 backend servers. It is not dependant on any specific configuration of the backend server such as JSESSIONID or PHPSESSIONID.
It will create a BALANCEID-cookie with a route to a backend server.
#You need at least these modules
#Header used for setting cookie
LoadModule headers_module ...
#Proxy
LoadModule proxy_module ...
LoadModule proxy_http_module ...
LoadModule proxy_balancer_module ...
#Set a cookie if BALANCER_ROUTE_CHANGED containing BALANCER_WORKER_ROUTE environment variable
Header add Set-Cookie "BALANCEID=hej.%{BALANCER_WORKER_ROUTE}e; path=/;" env=BALANCER_ROUTE_CHANGED
#Show balancer-manager
<Location /balancer-manager>
SetHandler balancer-manager
Order allow,deny
Allow from all
</Location>
ProxyRequests Off
#Configure members for cluster
<Proxy balancer://jakeri>
BalancerMember http://b1.jakeri.net:80 route=server1
BalancerMember http://b2.jakeri.net:80 route=server2
BalancerMember http://b3.jakeri.net:80 route=server3
</Proxy>
#Do not proxy balancer-manager
ProxyPass /balancer-manager !
#The actual ProxyPass
ProxyPass / balancer://jakeri/ stickysession=BALANCEID nofailover=Off
#Do not forget ProxyPassReverse for redirects
ProxyPassReverse / http://b1.jakeri.net/
ProxyPassReverse / http://b2.jakeri.net/
ProxyPassReverse / http://b3.jakeri.net/
I believe that this configuration is somewhat better compared to this guide.
I got to fix my css for the <code></code> :-/
Recent Comments