I'm doing a path rewrite to set and environment variable that will cause mod_jk to use a specific JBoss server. Works perfectly with any of the application paths.
When I try our monitoring servelet (does a simple db get to prove the stack is operational), it matches the rewrite, does the rewrite, sets the env var, but then fails to actually process the URL a second time.
Why the inconsistent behavior of the second trip through the rewrite engine?
Pattern is that if /workername/
is prepended to the path, it will remove but use that value as the JK_WORKER_NAME
for the mod_jk mount.
Example config:
SetHandler jakarta-servlet
SetEnv JK_WORKER_NAME mexico
RewriteEngine on
RewriteRule ^/(mexico[1-2])/(.*)$ /$2 [E=JK_WORKER_NAME:$1,L]
(mod_jk workers are named mexico1 and mexico2)
A hit to https://hostname/mexico2/public/gateway.sf
get a rewrite and then a second pass through the rewrite engine, processed by mod_JK and passed to the apps server. All good, see log (scroll right for good bits)
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde6fae0/initial] (2) init rewrite engine with requested uri /mexico2/public/gateway.sf
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde6fae0/initial] (3) applying pattern '.*' to uri '/mexico2/public/gateway.sf'
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde6fae0/initial] (4) RewriteCond: input='GET' pattern='^TRACE' => not-matched
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde6fae0/initial] (3) applying pattern '^/(mexico[1-2])/(.*)$' to uri '/mexico2/public/gateway.sf'
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde6fae0/initial] (2) rewrite '/mexico2/public/gateway.sf' -> '/public/gateway.sf'
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde6fae0/initial] (2) local path result: /public/gateway.sf
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde6fae0/initial] (2) prefixed with document_root to /data/publisher/webdav/images/notice/public/gateway.sf
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde6fae0/initial] (1) go-ahead with /data/publisher/webdav/images/notice/public/gateway.sf [OK]
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde84180/initial] (2) init rewrite engine with requested uri /public/gateway.sf
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde84180/initial] (3) applying pattern '.*' to uri '/public/gateway.sf'
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde84180/initial] (4) RewriteCond: input='GET' pattern='^TRACE' => not-matched
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde84180/initial] (3) applying pattern '^/(mexico[1-2])/(.*)$' to uri '/public/gateway.sf'
10.1.1.163 - - [26/Aug/2013:14:10:44 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde84180/initial] (1) pass through /public/gateway.sf
A hit to https://hostname/mexico1/monitorme.mmm
also matches the condition and gets rewrite, but then never gets a second pass through the engine and apache tries to server that path from the doc root. All hits are passed through to JBoss, there are no documents in the doc root. Thus I get a page not found.
10.1.1.163 - - [26/Aug/2013:14:12:17 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde71af0/initial] (2) init rewrite engine with requested uri /mexico1/monitorme.mmm
10.1.1.163 - - [26/Aug/2013:14:12:17 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde71af0/initial] (3) applying pattern '.*' to uri '/mexico1/monitorme.mmm'
10.1.1.163 - - [26/Aug/2013:14:12:17 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde71af0/initial] (4) RewriteCond: input='GET' pattern='^TRACE' => not-matched
10.1.1.163 - - [26/Aug/2013:14:12:17 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde71af0/initial] (3) applying pattern '^/(mexico[1-2])/(.*)$' to uri '/mexico1/monitorme.mmm'
10.1.1.163 - - [26/Aug/2013:14:12:17 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde71af0/initial] (2) rewrite '/mexico1/monitorme.mmm' -> '/monitorme.mmm'
10.1.1.163 - - [26/Aug/2013:14:12:17 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde71af0/initial] (2) local path result: /monitorme.mmm
10.1.1.163 - - [26/Aug/2013:14:12:17 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde71af0/initial] (2) prefixed with document_root to /data/publisher/webdav/images/notice/monitorme.mmm
10.1.1.163 - - [26/Aug/2013:14:12:17 --0400] [publisher.internal.test.hnw.com/sid#2ad8c96bc310][rid#2ad8bde71af0/initial] (1) go-ahead with /data/publisher/webdav/images/notice/monitorme.mmm [OK]