简体   繁体   中英

Enabling sticky session mode for Apache/Tomcat load balancing

I am trying to enable sticky sessions in Apache, however it is not working. Below are the changes made by me. Am I missing something?

I do not see any error in the access log, however request from one user is still going to other server.

Step 1 : Added below in httpd.conf of load balancer of server1 & server2

<Proxy balancer://marsBalancer>
BalancerMember http://server1fullname:8080  route=server1 
BalancerMember http://server2fullname:8080  route=server2
ProxySet lbmethod=bytraffic
ProxySet stickysession=JSESSIONID
</Proxy>
ProxyPass /marsWAR/ balancer://marsBalancer/marsWAR/

Step 2 : Updated below in server.xml

a) server.xml in server1

<Engine name="Catalina" defaultHost="localhost" jvmRoute="server1">    

b) server.xml in server2

<Engine name="Catalina" defaultHost="localhost" jvmRoute="server2">

Try removing the marsWAR part from the ProxyPass directive :

ProxyPass /marsWAR/ balancer://marsBalancer/

If it still does not work, try specifying the session <id> directly to the ProxyPass directive by adding the following code:

ProxyPass /marsWAR/ balancer://marsBalancer/ stickysession=JSESSIONID
  1. version numbers of everything = ?
  2. It has to be stickysession=JSESSIONID|jsessionid as Cookie name is uppercase, but path parameter name is lowercase. Supporting path parameters also needs scolonpathdelim=On [1] See also "Troubleshooting load balancer stickyness" on that documentation page.

[1] http://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html#stickyness_implementation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM