sticky session with apache web server and tomcat servers
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 ProxyPass
directive, use
ProxyPass /example http://backend.example.com stickysession=JSESSIONID
To be found in the excellent apache httpd documentation.
Pls try this, I'm sure this will work for you.
Step-1: Add below code in httpd.conf:
<Proxy balancer://mycluster>
BalancerMember http://<NODE1>/<APP>/ route=jvm1
BalancerMember http://<NODE2>/<APP>/ route=jvm2
ProxySet lbmethod=bytraffic
ProxySet stickysession=JSESSIONID
</Proxy>
ProxyPass /<APP>/ balancer://mycluster/
ProxyPassReverse /<APP>/ balancer://mycluster/
Step-2: Add below code in server.conf:
a) <NODE1>
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
b) <NODE2>
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm2">
This worked for me...
Instead of using stickysession=JSESSIONID in ProxyPass directive it has to be set within balancer configuration using ProxySet stickysession=JSESSIONID:
<Proxy balancer://mybalancer>
BalancerMember ajp://server1:8009 route=tomcat1
BalancerMember ajp://server2:8009 route=tomcat2
ProxySet lbmethod=bytraffic
ProxySet stickysession=JSESSIONID
</Proxy>
ProxyPass /myapp/ mybalancer://myapp/
It was not working for me when I was using it in ProxyPass as shown below:
ProxyPass /myapp/ mybalancer://myapp/ stickysession=JSESSIONID