Hi, On Thu, Jan 15, Shawn Heisey wrote: > On 1/15/2015 1:30 PM, Shawn Heisey wrote: > > Let's say that I have a server named 'friday' in my backend, and it has > > "cookie friday" on the server line. Let's also say that the web server > > sets the JSESSIONID with that server name in it, like this: > > > > JSESSIONID=6ED8B9D4544820B2C073579E17BF3A67.friday > > > > If I use "cookie JSESSIONID" in the backend config, will that see the > > cookie value in the cookie set by the server and send additional > > requests to that specific server? > > > > If that will work right, I was thinking of using "cookie JSESSIONID > > indirect preserve" ... would that be a reasonable config? I'm having a > > hard time figuring out from the documentation exactly what happens when > > the various options are combined. > > From what I can see in the log when I tried this configs on a staging > backend that only has one server, having ".friday" at the end of the > cookie does NOT work -- the third flag character is "I" which the docs > say means that an invalid cookie was found. Having a config option that > would allow this to work would be really nice.
Yes, I don't think haproxy "understands" tomcat's JSESSIONID.jvmRoute cookies. > With just "cookie JSESSIONID" all the flags are ----. With "cookie > JSESSIONID prefix" I get the expected --VN flags -- but it is haproxy > that decides which server to use, not the actual server. > > I'm using a completely different cookie (one that is not present in the > response from the application) for the production backend, and that > seems to be working really well: > > cookie SRV insert indirect postonly nocache > > The only problem I can foresee with that config is that haproxy's > persistence with the SRV cookie might send the request to friday, but > the JSESSIONID would cause the Apache cluster to then forward the > request to tomcat running on tanstaafl instead, and I'd like to avoid > that. If I could have haproxy learn what server needs to see the > request from the JSESSIONID cookie that tomcat sets (all servers run > both Apache and tomcat), inter-server traffic from user requests would > be kept to a minimum. Maybe it's possible to use some regexp to extract the jvmroute from JSESSIONID and set SRV cookie in haproxy ? Or use a tomcat filter that sets/changes SRV cookie if jvmRoute changes? > If haproxy already has a set of config options I can set that will have > it look for the server cookie value at the end of JSESSIONID, please let > me know what those options are. I think it would be useful to have a option in haproxy to use cookie JSESSIONID postfix|append, so haproxy could use tomcat's JSESSIONID=a1b2c3d4....jvmRoute cookies. -Jarno

