You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by re...@cemisid.ing.ula.ve on 2005/03/31 17:45:09 UTC

[users@httpd] Apache mod_rewrite and lost of cookies

Hi again!

I have written an email about the lost of Tomcat sessions when using
Apache as a reverse proxy. As this email was not answered, I had to find a
solutions by my self.

Since the Tomcat session are known in the client browser as a cookie, when
the request arrive to the JSP/Servlet in the container (Tomcat in this
case), I add, into the response, a cookie with the ID of the session. In
other words, the following line of code had to be added in almost every
JSP/Servlet in the webapp:

((HttpServletResponse)response).addCookie(new
Cookie("JSESSIONID",session.getId())) ;

This way, the client browser is forced to remember the session ID, so
Tomcat  knows which the correct session used by the client is.

It is easy to see that this solutions is a forced one. But, in fact, was
the only one I found until now.

I think that the original problem might be caused by the lost of cookie's
content when the request goes through Apache. Perhaps when the URL is
rewritten this info is also rewritten.

Thank you for all....

Jorge



> Hi apache users!
>
> I am using Apache 2.0 (as a reverse proxy) + Tomcat 5.5.
>
> The problem I have is that when accesing my Tomcat webapp through apache
> proxy, the session is lost, a new session is created. This does not
> happend when accesing the webapp directly from browser to tomcat.
>
> Is there anybody who knows how to do it...
>
> Thank you very much...
>
> Jorge
>
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: Tomcat session lost with mod_rewrite+mod_proxy

Posted by ramou <st...@cs.concordia.ca>.
I ran into your problem too. Your fix tugged something in my brain so I
went and looked it up. Here is the sort of fix you were looking for:

'mod_proxy - Apache HTTP Server'
(http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse)

ProxyPassReverseCookiePath / /mirror/foo/

where the above paths are the paths on the ProxyPassReverse directive
you'd used. In my particular case:

RewriteEngine on
RewriteRule ^/group0n/(.*) http://localhost:8080/group0n/$1 [P]
RewriteRule ^/servlet/(.*) http://localhost:8080/group0n/$1 [P]
ProxyPassReverse /servlet/ http://localhost:8080/group0n/
ProxyPassReverseCookiePath /group0n/ /servlet/

I don't understand how my students worked without sessions for 10 weeks
and only one of them pointed out that something was wrong?


-- 
ramou
------------------------------------------------------------------------
ramou's Profile: http://unixadmintalk.com/1512
View this thread: http://unixadmintalk.com/showthread.php?t=42935



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org