tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Different session id per page
Date Sun, 01 Jan 2012 20:08:12 GMT
Jerry Malcolm wrote:
> Andre,
> 
> In mod_rewrite it talks about setting a cookie when a rewrite rule hit
> occurs. But I can't find anything about back-translation of cookie paths.
> Was that was what you meant?  Still not sure how that would work.  Seems
> like i would need a way to tell the browser that URLs /cart,
> /locateaccount, /checkout all use the /order cookie.  How would that work?
> 
In perl (programming language) circles, we use the TIMTOWTDI acronym to mean "there is 
more than one way to do it", which is true for most things in perl.
To connect Apache and Tomcat, this applies too, which does not make for easy or short 
explanations..

By now, you already got a few hints from Chuck and Rainer and others, but here is the 
grand scheme :

To proxy requests from Apache to Tomcat, there are 3 methods :
a) using mod_proxy and HTTP :
    Apache + mod_proxy + mod_proxy_http <-- HTTP(S) protocol --> Tomcat HTTP(S) Connector
b) using AJP :
b.1) using mod_proxy and AJP :
    Apache + mod_proxy + mod_proxy_ajp <-- AJP protocol --> Tomcat AJP Connector
b.2) using mod_jk and AJP :
    Apache + mod_jk  <-- AJP protocol --> Tomcat AJP Connector

Each of the above methods has advantages and inconvenients, and its own fan club.

If you are using (a) or (b.1), then you are using mod_proxy at the Apache level, and you 
have access to the directives which mod_proxy provides, which include the
ProxyPassReverseCookiePath
directive, which would do exactly what you want.
(http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreversecookiepath)
Also, with the ProxyPass directive, you can do some of the URL rewrite logic which you 
currently do with mod_rewrite.
For example, you can rather easily do things like
ProxyPass /original/url ajp://tomcat/some/other/url
And if you need more complicated rewriting, you can use mod_rewrite and mod_proxy in 
succession (mod_rewrite does its thing first, and then mod_proxy proxies).

If you are using (b.2) at the Apache level, then things are a bit more complicated, if you

are also using mod_rewrite to rewrite the URLs before proxying the requests to Tomcat.
That's because mod_jk itself does not provide a directive that is equivalent to the 
mod_proxy "ProxyPassReverseCookiePath" directive.
So in that case, you would use another Apache module (mod_headers, see 
http://httpd.apache.org/docs/2.2/mod/mod_headers.html), to rewrite the "Set-Cookie" 
response headers which come back from Tomcat, before they are sent back to the browser.
(That is what Rainer was hinting at).

Or, you could do the cookie manipulation at the Tomcat level, which in your case might be

the easiest thing to do and is valid no matter how you set up the front-end.
(That is what Chuck is talking about, with a complement by Rainer).

Hope this makes things a bit clearer.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message