Web Servers on Unix and Linux - Rewriting URL to URL with apache2.0.48

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers on Unix and Linux > April 2004 > Rewriting URL to URL with apache2.0.48





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Rewriting URL to URL with apache2.0.48
merkelw

2004-04-29, 10:36 am

We are working in an apache2.0.48/tomcat4.1.29/mod_jk2 environment.
Our J2EE Application consists of several different webapplications,
using different URI-Contexts (e.g. /webapp1, /webapp2, /webapp3)
within the tomcat servlet engine.

All URLs provided for external users will hide these URL-Prefixes
completely from the end user.

The apache2 webserver will do compression (mod_deflate) and will
deliver cached pages from the webapps directly to the enduser.
Requests to not yet cached pages are to be forwarded to one of the
webapps.

Traditional solution using mod_rewrite / mod_proxy is working fine.
-------------------------------------------------------------------
Traditionally we used Rewrite Rules, proxypassing Requests from
outside directly to the tomcat...

RewriteRule /Pattern.* http://localhost:8080/webapp1/%{REQUEST_URI}
[P,L]

Problem with this solution:
client connections end up at the apache. Apache starts a new
connection to the tomcat. This makes problems, if the web application
needs to check the client ip, because tomcat requests receive always
remote_addr localhost from the apache connection.


Changing to mod_jk2 & mod rewrite
--------------------------------

Our mod_jk2 integration for apache2 looks like this...
<VirtualHost localhost:9100>
<Location /webapp1>
JkUriSet worker ajp13:localhost:9108
</Location>
</VirtualHost>

All requests to the http://localhost:9100/webapp1/... are passed
directly to the tomcat servlet enging.

To hide the URI-Prefix of the different webapps, we provide a rewrite
rule like this...
<VirtualHost localhost:9100>
RewriteEngine on
RewriteRule /SomePatternMatching.* /webapp1/%{REQUEST_URI} [PT]

<Location /webapp1>
JkUriSet worker ajp13:localhost:9108
</Location>
</VirtualHost>

RewriteLog looks fine (Rule is matching, "forcing
'/webapp1/-/id=1860/index.html' to get passed through to next API
URI-to-filename handler"
But the result ist still 404 or 403, with no JK-forwarding to the
tomcat.

The problem is, that apache will not resolve this new URL to reach the
<Location /webapp1> handler.

Changing the Rewrite Rule Flag from [PT] to [P] will work fine again,
but that's not what I intend to do, because I have to avoid
ProxyPassing requests (because they loose the client ip).

The Problem seem to be part of the basic rewriting mechanism of apache
and the difference in reqwrting URL-->Filename and URL-->URL.
Internally it seem to be always URL-->Filename and this will avoid
falling into a <Location> Handler with a redirected URL.

It would be great if, there is someone who can help.

Bye

Wolfgang Merkel
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com