I am using apache web server as a load balancer for two tomcat instances behind apache. When the first request goes to node A and second request from the same client goes to node B, i cant access session variables within node A. It’s obvious. I surfed in the internet and found that enabling sticky sessions would help. But all the tutorials for enabling the sticky sessions in apache look confusing. Is there any simple step-by-step tutorial for this? Please help.
Code fragment from comment:
ProxyPass /balancer-manager !
ProxyPass /balancer://mycluster/ stickysession=JSESSIONID
ProxyPassReverse /balancer://mycluster/
<Proxy balancer://mycluster>;
BalancerMember ajp://localhost:9001/ route=NodeA1000 retry=10
BalancerMember ajp://localhost:9002/ route=NodeB1000 retry=10
</Proxy>
For apache httpd to keep your sessions tied to the same backend, it needs to know which cookie keeps the session ID. For java, this is (usually) JSESSIONID.
If you’re using the
ProxyPassdirective, useTo be found in the excellent apache httpd documentation.