Bug 42038 - JK uriworkermap ROOT mapping causes non-virtual exclusions to be ignored
JK uriworkermap ROOT mapping causes non-virtual exclusions to be ignored
Status: RESOLVED FIXED
Product: Tomcat Connectors
Classification: Unclassified
Component: Common
unspecified
PC Windows Server 2003
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
: PatchAvailable
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-04-03 14:14 UTC by Steve Coffman
Modified: 2008-10-05 03:10 UTC (History)
0 users



Attachments
log file for the ISAPI Redirector (13.10 KB, text/plain)
2007-04-04 12:16 UTC, Steve Coffman
Details
Corrected version of files from 1.2.21 (63.41 KB, application/octet-stream)
2007-04-11 10:42 UTC, Steve Coffman
Details
Altered Files against 1.2.22 (68.24 KB, application/zip)
2007-04-11 14:13 UTC, Steve Coffman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Coffman 2007-04-03 14:14:41 UTC
Exclusion rules that differ from non-excluded mappings only by case appear to be
ignored.

With JK 1.2.20 installed on IIS on Windows 2003, and
given the following in uriworkermap.properties:

/umich|/*=v7CDALiveWorker
#Added for Friendly URL Mapper
/*=v7CDALiveWorker
#Exclude static files
!/UMICH/*=v7CDALiveWorker
!/System/*=v7CDALiveWorker

Requests to /umich are sent appropriately to Tomcat. [Correct]
Requests to /UMICH are sent to Tomcat (resulting in a Tomcat 404 error) [Bug]
Request to /System are sent to IIS, NOT Tomcat. [Correct]

Somehow I think it's the case sensitivity, but the fact that there's a Root
context might complicate things. I've tried looking through the source code, but
 it's beyond me to figure out what's going on.
Comment 1 Steve Coffman 2007-04-04 12:16:07 UTC
Created attachment 19914 [details]
log file for the ISAPI Redirector

This is the log file, set to debug.
Comment 2 Steve Coffman 2007-04-04 13:10:36 UTC
Turns out it has nothing to do with case. The presence of a root context mapping
means that any exclusion rules such as "!/UMICH" appear to be ignored. I had an
old /System context that was causing that to properly work (Tomcat was serving
the static files). 

Requests to /umich are sent appropriately to Tomcat. [Correct]
Requests to /UMICH are sent to Tomcat (resulting in a Tomcat 404 error) [Bug]
Request to /System  sent to Tomcat (resulting in a Tomcat 404 error) [Bug]

I have updated the summary to reflect this.
Comment 3 Steve Coffman 2007-04-09 17:12:58 UTC
On IIS, if you have a root context rule, you must specify the virtual host for
any exclusion rules for them to correctly identify a no match. This occurs in jk
1.2.20 and 1.2.21. This appears to be because jk_isapi_plugin.c (line 870-875 in
1.2.21) checks for successful map_uri_to_worker (with is always true when there
is a root context rule) with the Virtual Host Redirection before attempting a
Default redirection map_uri_to_worker. 

For example a uriworkermap.properties file:

/*=v7CDALiveWorker
#Exclude static files (take turns commenting out the following for testing)
!/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/UMICH/*=v7CDALiveWorker
!/UMICH/*=v7CDALiveWorker

If you omit the virtual host line, then it fails to find the non-virtual
exclusion rule (This means it does not successfully find a  wildchar no match).

Without the virtual host line, it compares:
jk_uri_worker_map.c (161): wildchar_match(str, exp)  for
/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/UMICH/MichInWash/Home/For Students/Fall
Application Information/MIWF07app.pdf compared to /UMICH/*

With only the virtual host line, it compares:
jk_uri_worker_map.c (161):wildchar_match(str, exp)  for
/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/UMICH/MichInWash/Home/For Students/Fall
Application Information/MIWF07app.pdf compared to
/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/UMICH/*


Comment 4 Steve Coffman 2007-04-09 17:15:06 UTC
Sorry. Correcting version information for latest connector.
Comment 5 Mladen Turk 2007-04-10 07:08:18 UTC
Hi,

> /*=v7CDALiveWorker
This is wrong.
In case you have multiple virtual hosts you shuld never do that.
Always use the /VHOST/URI form:
/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/*=v7CDALiveWorker
or at least ...
/*/*=v7CDALiveWorker

> #Exclude static files (take turns commenting out the following for testing)
> !/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/UMICH/*=v7CDALiveWorker
> !/UMICH/*=v7CDALiveWorker

Again, use the:
!/*/UMICH/*=v7CDALiveWorker

There is simply no way to know what the virtual host is from the
uriworkermap.properties unless we change the configuration, and
mark the VHOST part somehow. That would make configs backward incompatible,
so it'll have to wait some post 1.2 version
Comment 6 Steve Coffman 2007-04-11 10:42:07 UTC
Created attachment 19932 [details]
Corrected version of files from 1.2.21

Attached is a patch which corrects the behavior to match the documentation.
This allows a site without multiple virtual hosts to use a
uriworkermap.properties such as:

/*=v7CDALiveWorker
/umich|/*=v7CDALiveWorker
#Exclude static files
!/UMICH/*=v7CDALiveWorker
!/StaticFiles/*=v7CDALiveWorker
!/System/*=v7CDALiveWorker
!/Humin-migration/*=v7CDALiveWorker

It also allows a site with multiple virtual hosts to use a
uriworkermap.properties like:
/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/*=v7CDALiveWorker
/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/umich|/*=v7CDALiveWorker
#Exclude static files
!/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/UMICH/*=v7CDALiveWorker
!/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/StaticFiles/*=v7CDALiveWorker
!/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/System/*=v7CDALiveWorker
!/lsa-cmsdev1.lsa.adsroot.itcs.umich.edu/Humin-migration/*=v7CDALiveWorker

I have submitted the complete altered files rather than a patch because I do
not know the patch format preferred, and I am concerned I did not correctly
follow the tab/spacing standards. Also, I believe the files have changed since
the last release, and a patch may not cleanly apply. Let me know if you would
like me to correct these.
Comment 7 Steve Coffman 2007-04-11 10:47:58 UTC
I believe that the current behavior is contrary to the documentation, and that
altering the configuration file format is not necessary to solve it. My attached
solution may break working configurations that mixed and matched virtual with
non-virtual mounts, but it may not. I would like someone who is more familiar
with the code and C to examine my solution, as I may have overlooked something.
Comment 8 Steve Coffman 2007-04-11 14:13:16 UTC
Created attachment 19934 [details]
Altered Files against 1.2.22

This updates the files to be against the
tomcat-connectors-1.2.22-dev-527493-src.zip that Mladen made available. You can
uncompress them as an overlay.
Comment 9 Steve Coffman 2007-04-15 18:16:23 UTC
Adding keyword because there is a patch attached.
Comment 10 Steve Coffman 2007-10-04 09:36:14 UTC
Is there any reason why this patch has not been applied?
Comment 11 Rainer Jung 2007-11-03 14:16:45 UTC
1) case-sensitivity

Most parts of URLs are case-sensitive in general (as stated by the respective
RFCs). Although on the windows platform file system pathes are not, and
therefore URLs pointing to file system objects usually behave case-insensitive,
mod_jk decides about forwarding to backends, whose case-sensitivity is unknown.

So we wont change the default for the Windows platform to case-insensitive. One
might argue, that it would make configuration for the windows platform easier,
if one could choose mappings to be case insensitive (not active by default). For
this we could extent the syntax of uriworkermap.properties resp. JkMount (in the
apache case). If you think that's an important feature, please open a separate
BZ for this feature and people can discuss it.

2) Root-Context mounts and unmounts

I'm thinking about your patch resp. something close to it.
Comment 12 Rainer Jung 2007-11-04 10:22:32 UTC
Your configuration

/umich|/*=v7CDALiveWorker
#Added for Friendly URL Mapper
/*=v7CDALiveWorker
#Exclude static files
!/UMICH/*=v7CDALiveWorker
!/System/*=v7CDALiveWorker

should now work (apart from the fact, that we still match URLs case sensitive).
You can find a dev snapshot of 1.2.26 under

http://people.apache.org/~rjung/mod_jk-dev/

The IIS mount checks are restructured now. They should be compatible as long no
exclusion is defined. Whenever an exclusion is defined, it is always matched
last, after any positive match, independeant of possible vhosts.

Please report back, if this fixes your problem.