[ale] problem with mod_rewrite (Apache 2.0 + mod_jk / tomcat5)

Jerry Yu jjj863 at gmail.com
Fri Jan 26 13:41:27 EST 2007


Thanks, Jeremy. That was how it is configured on our site as well.
The mod_rewrite I am attempting is to cover the scendario when Tomcat is
down for maintenance purpose. So, we want to send any request (blah.jsp or
otherwise) to a static page on the same server, when tomcat is down.

On 1/26/07, Jeremy T. Bouse <Jeremy.Bouse at undergrid.net> wrote:
>
>         I'm using Apache2 with mod_jk to communicate with a Tomcat 5.5server
> on a couple of machines but I've not bothered to try and handle it in
> this manner. I make use of JkAutoAlias, JkMount and JkUmount to handle
> all the mod_jk configurations I've used. That with some specially
> crafted mod_rewrite rules to do some redirection and handle static file
> overlays. Most of the web apps I'm doing this for on Tomcat are not ROOT
> contexts and there might be a better way to set them up in Tomcat as
> virtual hosts with ROOT contexts but haven't dug into it as it works as
> is.
>
>         What I have for each Apache2 virtual host is the following:
>
> <VirtualHost x.x.x.x:80>
>   . . .
>   <IfModule mod_rewrite.c>
>      RewriteEngine on
>
>      RewriteCond /var/www/html%{REQUEST_FILENAME} -f
>      RewriteRule ^(.+)          /var/www/html$1 [L]
>
>      RewriteRule ^(.+)          - [PT]
>   </IfModule>
>
>   <IfModule mod_alias.c>
>      RedirectMatch ^/$ /context
>   </IfModule>
>
>   <IfModule mod_jk.c>
>      JkAutoAlias /usr/share/tomcat5/webapps
>
>      JkMount /context/* default
>
>      JkUmount /context/images/* default
>   </IfModule>
> </VirtualHost>
>
>         This allows me to create /var/www/html/context/path/to/file and it
> will
> be handled by Apache if it exists otherwise handed to Tomcat. Now to do
> this though you have to JkUmount the "path" so in the example only
> /var/www/html/context/images/ would be overlayed.
>
>         Not sure if this might give you some ideas at another way to
> approach
> it or not. Again I'm not sure if this is the best way but it is the way
> I have a couple sites that handle a fair amount of traffic are configured.
>
>         Regards,
>         Jeremy
>
> Jerry Yu wrote:
> > hi,
> > I wanted to redirect everything to a static outage page on an Apache 2.0
> > server on Linux with mod_jk connecting to a tomcat5 instance.  The
> > rewrite rules worked, per mod_rewrite.log. However, for anything *.jsp,
> > I got 500 internal error and mod_jk.log shows failed attempts to connect
> > to Tomcat, which I stopped on purpose. For others, I got my static HTML
> > page as intended.  I thought it wouldn't go to Tomcat/mod_jk at all, if
> > rewriting happens before the jkMount mapping to .jsp files.
> > Per some tips found by Google, I shuffled LoadModule statement for
> > mod_jk and mod_rewrite back & forth, to no avail. Any one ran into this
> > before?
> >
> > ------------------------- httpd.conf-------------------------------
> > LoadModule    jk_module  modules/mod_jk.so
> > LoadModule rewrite_module modules/mod_rewrite.so
> >
> > JkWorkersFile /etc/httpd/conf/tomcat_workers.properties
> > JkLogFile /var/log/httpd/mod_jk.log
> > JkLogLevel info
> > JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
> > JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
> > JkRequestLogFormat "%w %V %T"
> > <VirtualHost *:80>
> >    DocumentRoot "/var/www/html/blahWEB"
> >    JkMount /*.jsp blah
> >    JkMount /*.m blah
> >    JkMount /*.jws blah
> >    JkMount /servlet/sendfile/* blah
> >    JkMount /probe*/* blah
> >
> >        ProxyRequests off
> >
> >         RewriteEngine on
> >         RewriteLog      logs/mod_rewrite.log
> >         RewriteLogLevel  4
> >         # redirect all request to a static page except gif/html
> >         RewriteCond %{THE_REQUEST} (HTTP/1.1) [NC]
> >         RewriteRule ^/(.*gif)$ /$1 [L]
> >         RewriteRule ^/(.*html)$ /$1 [L]
> >         RewriteRule ^/(.*)$ /msg/outage.html [L]
> >
> > </VirtualHost>
> > -------------------------httpd.conf-------------------------------
> >
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list