You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by André Warnier <aw...@ice-sa.com> on 2012/11/05 11:12:55 UTC

Re: mod_jk and mod_rewrite

Pete Storey wrote:
> Hi
> 
> I've got what I think is a pretty normal setup, where I have an Apache
> server serving some content for a website, and using mod_jk to connect to
> Tomcat running on another server.  My problem is that I'm also trying to
> use mod_rewrite to ­ err, rewrite URLs.  In short, if I do this the
> 'normal' way and include rewrite directives in the .htaccess file for the
> website, it doesn't work and they are ignored, however if I put them in
> the main httpd.conf file, before the JkMount directive, then they do work.
> 
> This appears to be a case of a problem with the order in which
> modules/filters hook into Apache and are run;  I have looked at the
> documentation and searched about for answers on this but found nada.  I've
> tried using the various JkOptions setups but it doesn't seem to achieve
> much.
> 
> In my httpd.conf, mod_rewrite is loaded before mod_jk though I don't think
> this matters especially.
> 
> Some potentially relevant config -
> 
> - in httpd.conf
> 
> <Directory />
>     Options FollowSymLinks
>     AllowOverride None
> </Directory>
> 
> <Directory "/var/www/html">
> 
>     Options -Indexes +FollowSymLinks
> 
>   <LimitExcept GET HEAD POST>
>      deny from all
>   </LimitExcept>
> 
>     AllowOverride All
> 
>     Order allow,deny
>     Allow from all
> 
> </Directory>
> 
> AccessFileName .htaccess
> 
> JkWorkersFile /etc/httpd/conf/workers.properties
> JkShmFile     /var/log/httpd/mod_jk.shm
> # Rotate weekly
> JkLogFile     "|/usr/sbin/rotatelogs /var/log/httpd/mod_jk.log 604800"
> JkLogLevel    warn
> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
> #JkOptions     +ForwardURIProxy
> 
> - Inside the (included into httpd.conf) virtual host.conf file
> 
> 
> 
>     RewriteEngine on
>     Include vhosts/htaccess/mysite.htaccess
> 
> # Mount all to Tomcat
>     JkMount /* mysite
> # Handle images locally
>     JkUnMount /*.gif mysite
>     JkUnMount /*.jpg mysite
>     JkUnMount /*.jpeg mysite
>     JkUnMount /*.png mysite
> 
> - Inside the my site.htaccess file (example line)
> 
> 
> 
> # McAfee secure image
> RewriteRule ^/assets/cached/mcafee\.png /assets/php/mcafeeimage.php [L,NC]
> 
> Now this all works fine - except that I have to have a file which is
> directly included into the httpd.conf, and which thus requires the server
> to be restarted every time you want to make a change.  On top of that, if
> there is a problem in the file, then the whole server will fail to start,
> which is clearly far from ideal.
> 
> Is there a way to hook in the RewriteEngine in .htaccess rather than
> having to include them like this?  I can't believe I am the first person
> to discover this/have this setup?
> 

A side suggestion : in one of the on-line documentation pages reative to the mod_jk 
configuration, at the very bottom of the page, it shows another "configuration style" : 
instead of using JkMount/JkUnmount, you use an Apache <Location> (or <LocationMatch>) 
section, with a line :

SetHandler jakarta-servlet

This does not really change anything in terms of how it works deep down, but it makes it 
much clearer (in my view) how the order of precedence is determined at the Apache level.
The "SetHandler" directive indicates what the "Apache response handler" is, and this fits 
better in the global Apache request/response cycle, allowing one to figure out which thing 
runs before/after what.



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