I have the following requirements
- Multiple JARs. Each running an embedded Jetty.
- Run everyone on same domain/port - using reverse proxy (Apache)
- A JAR can have multiple instances running on different machines (yet under same host/port).
- Complete session separation - absolutely no sharing even between 2 instances of same webapp.
- Scale this all dynamically.
- I do not know if this is relevant, but I know Spring Security is used in some of these web apps.
I got everything up and running by adding reverse proxy rules and restarting Apache. Here is a simplified description of 2 instances for webapp-1 and 2 instances for webapp-2.
http://mydomain.com/app1 ==> 1.1.1.1:9099
http://mydomain.com/app2 ==> 1.1.1.1:9100
http://mydomain.com/app3 ==> 1.1.1.2:9099
http://mydomain.com/app4 ==> 1.1.1.2:9100
After setting this up successfully (almost), we see problems with JSESSIONID cookie. Every app overrides the others' cookie - which means we have yet to achieve total session separation as one affects the other.
I read a lot about this issue online, but the solutions never really suffice in my scenario.
The IDEAL solution for me would be to define JETTY to use some kind of UUID for the cookie name. I still cannot figure out why this is not the default.
I would even go for a JavaScript solution. JavaScript has the advantage that it can see the URL after ReverseProxy manipulation. So for http://mydomain.com/XXX
I can define cookie name to be XXX_JSESSIONID
.
But I cannot find a howto on these.
So how can I resolve this and get a total separation of sessions?