I have found that the value of my jsessionid
cookies is value.*tomcatid*
– e.g jsessionid=ahvrbsbbdhdhwh.tc12
.
Where can I find the configuration of the Tomcat ID which is being concatenated with the jsessionid
value?
The suffix you are seeing is called the jvmRoute
and is configured in mod_jk's workers.properties
file as either the name of the worker:
worker.tc12.type=AJP13
(etc)
or by explicitly setting the name of the route
property:
worker.longname.type=AJP13
worker.longname.route=tc12
(etc)
In Tomcat, the jvmRoute
is set in conf/server.xml
on the <Engine>
element:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tc12">
If you want to change the route names, you will need to adjust both your mod_jk and Tomcat configurations to match each other.
If you want to remove this suffix, then you will have to disable sticky sessions in mod_jk (sticky sessions are the default configuration) and also remove the jvmRoute
attribute in your conf/server.xml
:
workers.properties
------------------
worker.rc12.sticky_session = false
and:
conf/server.xml
---------------
<Engine name="Catalina" defaultHost="localhost">
This will disable sticky sessions which means that every request will go to an arbitrary Tomcat server.
Even if you do not need sticky sessions (e.g. because you are using clustered Tomcats, mirgatable sessions, or you have a stateless web service), it might be a good idea to leave them enabled the the following reasons:
Note that sessions are never sticky if your Tomcat nodes do not have any jvmRoute
defined in the <Engine>
component. So you can effectively disable session stickiness by removing your jvmRoute1
s in your conf/server.xml
files and no other re-configuration is necessary.