Apache load balancing when the session id is in url

Maybe your configuration is wrong. Documentation is not specified sticky-session working only cookies.

stickysession - Balancer sticky session name. The value is usually set to something like JSESSIONID or PHPSESSIONID, and it depends on the backend application server that support sessions. If the backend application server uses different name for cookies and url encoded id (like servlet containers) use | to to separate them. The first part is for the cookie the second for the path.

So you can specify the sessionid like below.

ProxyPass / balancer://mycluster/ stickysession=|jsessionid

Hope this helps.


For creating the sticky we need to add the following line in your configuration(mod_proxy)

Header add Set-Cookie "BALANCEID=hej.%{BALANCER_WORKER_ROUTE}e; path=/;" env=BALANCER_ROUTE_CHANGED

Then specify the route name in the config

<Proxy balancer://mycluster>
    BalancerMember http://tomcat sever1.ip:8080  route=AcZxv
    BalancerMember http://tomcat server2.ip:8080 route=AcXxv
    lbmethod=byrequests stickysession=BALANCEID
</Proxy>

And add these routenames to tcserver.node in catalina.properties of tomcat servers

tcserver.node=AcZxv (tomcat 1st server)
tcserver.node=AcXxv (tomcat 2nd server)