tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: [OT] Using httpd's mod_rewrite with mod_jk
Date Thu, 01 Jul 2010 09:47:26 GMT
Rainer Jung wrote:
> On 30.06.2010 19:00, Christopher Schultz wrote:
>> Slightly off-topic, but relevant.
>>
>> On our development servers, I'm trying to enforce a rule that all our
>> users have the most up-to-date web browser available (yeah, it's an
>> uphill battle, I know... just go with it).
>>
>> I decided to use mod_rewrite to check for a User-Agent pattern and then
>> forward to a "bad browser" page, which works well for static content,
>> but not for requests destined to be handled by mod_jk.
>>
>> Here's what I've got:
>>
>>          # Handle Mozilla Firefox
>>          RewriteCond %{HTTP_USER_AGENT} Firefox/
>>          RewriteCond %{HTTP_USER_AGENT}
>> !(Firefox/(3\.0\.19|3\.5\.9|3\.6\.3)($|[^\.0-9]))
>>          RewriteRule .* /bad-browser.shtml [L]
>>
>> For dynamic requests, this will happily allow the request to go through
>> to mod_jk.
> 
> Usually mod_rewrite is perfectly compatible with mod_jk. I must confess, 
> that I'm not 100% sure about the case, where you try to rewrite a 
> request that originally would have been handled by mod_jk to something 
> that should not be handled by it.
> 
> Two possibilities: if it doesn't actually work, you can set the env var 
> "no-jk" as a side effect in your rewrite rule. If mod_jk fins this env 
> var set, it will decline to handle the request. Alternatively, if you 
> are fine with redirecting by mod_rewrite instead of rewriting 
> internally, the redirecting should also win over mod_jk.
> 
> There is a chance though, that it should work out of the box and you are 
> using some indirect mapping to mod_jk that wins. That would be the case 
> if you are either using one of the outdated "JkOptions ForwardXXX" 
> options, or you are using an indirect mapping like setting the handler 
> to "jakarta-servlet", or using the environment variable trick 
> (JK_WORKER_NAME or JkWorkerIndicator) to define the target worker.
> 
> So you might want to tell us, how you map your dynamic requests 
> (JkMount, setting handler etc.) to mod_jk and what other Jk directives 
> (like JkOptions) you are using.
> 
> To complete the picture: in cases were the RewriteRule works, but then 
> the request is not forwarded via mod_jk although it should, you need to 
> add the PT flag. In your case I guess its the opposite situation you are 
> looking for.
> 
Hi.
I usually find helpful the Apache httpd request processing cycle diagram found here :
http://perl.apache.org/docs/2.0/user/handlers/http.html
That page is part of the mod_perl documentation, explaining how the Apache/perl 
integration works.  But since mod_perl digs deep inside Apache httpd, the various stages 
of request processing by mod_perl follow the internal Apache httpd cycle very closely.
For example, it helps in figuring out at what stage and in what order things like 
mod_rewrite, JkMount, <Location>, content handlers etc.. play a role, how they combine,

and at which level you can intervene to do what.
It must exist somewhere, but I have not yet found an original Apache httpd document which

explains these things so well.
Forget the perl-specific stuff that you find there, just follow the explanations and the 
links.  It is really a good tutorial into the insides of Apache httpd's request processing.


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


Mime
View raw message