Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache ProxyPass and Sessions

So I'm using Apache to proxy a specific folder to a Glassfish instance. The rules in my conf are:

ProxyPass /folder http://localhost:28083
ProxyPassReverse /folder http://localhost:28083
ProxyPassReverseCookiePath /folder http://localhost:28083

It's working fine, except for the sessions. For every subfolder a new session is created.

So while I stay in one folder, the session persists, but as soon as I jump into another folder a new session is made.

How can I have one session for all subfolders?

like image 280
caspermc Avatar asked Dec 30 '11 06:12

caspermc


2 Answers

As covener already mentioned, the second parameter of ProxyPassReverseCookiePath should be a path. Be aware that the parameters are switched compared to the other directives, so in your case it would be:

ProxyPassReverseCookiePath / /folder

(Technically, this should not be necessary for it to work, as cookies from the path / are also available in /folder/, but it might cause them to interfere with the cookies of other web applications that you are running on the same domain.)

In addition, you might want to transform the cookie domain as well (unless you access your application only through http://localhost/folder/):

ProxyPassReverseCookieDomain localhost example.com

example.com is the domain over which your web application is accessed.

like image 155
cdauth Avatar answered Nov 17 '22 20:11

cdauth


ProxyPassReverseCookiePath's 2nd parameter should just be a path, not a full URL. Apache can't properly fixup the path baked into the cookie w/ the current invalid usage.

like image 39
covener Avatar answered Nov 17 '22 22:11

covener