7.1.3 Using JSESSIONID

This configuration provides a way for load balancing using JSESSIONID.

In JBoss application server, tomcat container adds the name of the instance to the end of its session id cookie, separated with a dot (.) from the session id. Thus if the Apache web server finds a dot in the value of the session persistence cookie, it only uses the part behind the dot to search for the route. For Tomcat Server instance ro be aware of its instance name, set the attribute jvmRoute inside the JBoss configuration file deploy/jbossweb.sar/server.xml to the value of the route of the worker that connects to the respective JBoss. The name of the session cookie used here is JSESSIONID.

Add following configuration to APACHE_HOME/conf/httpd.conf file.
<VirtualHost *:80> 
ServerName lb.xyz.com 
ServerAlias lb.xyz.com 
ProxyRequests Off 
ProxyPreserveHost On 
<Proxy balancer://cluster> 
BalancerMember http:// abc.com:8080 route=node1 
BalancerMember http:// xyz.com:8080 route=node2 
</Proxy> 
ProxyPass / balancer://cluster/ stickysession=JSESSIONID|jsessionid 
ProxyPassReverse / balancer://cluster/ 
</VirtualHost>
Server-Side Configuration
  1. For each node in the cluster, open the server.xml file in a text editor from this location: [appserver root]/server/<profile_name>/deploy/jbossweb.sar

  2. Search the server.xml file for the Engine name element and add a jvmRoute attribute. For example, on a node named node1, edit the element to read as follows:<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1">

  3. Save the edited server.xml file.

Note: : For each cluster node, the value of jvmRoute must be unique and match to the value of the route of the worker that connects to the respective JBoss Server(See BalancerMember Configuration in httpd.conf).

// Ethnio survey code removed