Obscureciendo la ruta del context de tomcat en la URL

He configurado un proxy inverso de Apache a Tomcat que está funcionando, en que puedo cargar mi url y get connection con el backend de Tomcat. Lo que estoy tratando de hacer ahora es reescribir la URL que un usuario ve en su browser. Aquí está mi código –

LoadModule proxy_html_module modules/mod_proxy_html.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so # DON'T TURN ProxyRequests ON! Bad things will happen ProxyRequests off # Enabling mod_proxy_html ProxyHTMLEnable On ProxyHTMLLogVerbose On LogLevel Debug SSLProxyEngine on # Setup mod_proxy_ajp load balancer to the 2 happ hosts <Proxy balancer://happcluster> BalancerMember ajp://happ01.domain.com:8009 loadfactor=1 BalancerMember ajp://happ02.domain.com:8009 loadfactor=1 ProxySet lbmethod=bytraffic ProxySet stickysession=JSESSIONID </Proxy> # rewrite setup RewriteEngine On RewriteLog /var/log/httpd/rewrite_log RewriteLogLevel 8 RewriteCond %{HTTP_HOST} !^www.* [NC] RewriteCond %{HTTP_HOST} ^app\.domain\.com$ [NC] RewriteCond %{REQUEST_URI} !^/app1/.*$ RewriteCond %{REQUEST_URI} !^.*\.ico$ [NC] RewriteRule ^(/.*) balancer://happcluster/app$1 [P] # Necessary to have mod_proxy_html do the rewriting RequestHeader unset Accept-Encoding # Be prepanetworking to rewrite the HTML/CSS files as they come back # from Tomcat SetOutputFilter proxy-html SetOutputFilter INFLATE;DEFLATE # Rewrite JavaScript and CSS files in addition to HTML files ProxyHTMLExtended On # Output Strict XHTML (add "Legacy" to the end of the line below # to output Transitional XHTML) ProxyHTMLDoctype XHTML # Rewrite HTTP headers and HTML/CSS links for everything else ProxyPassReverse /app1/ / ProxyPassReverseCookiePath /app1/ / ProxyHTMLURLMap /app1/ / 

Lo que ocurre es que cuando escribo http://app.domain.com en un browser, la URL se vuelve a escribir en http://app.domain.com/app1/ …..

Estoy utilizando mod_proxy_ajp para cargar las requestes de equilibrio a 2 back-end serveres tomcat y esto parece estar funcionando.

¿Algunas ideas?

EDITAR

He aquí un fragment de mi logging de reescritura que muestra el proxy al backend –

 [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (2) init rewrite engine with requested uri / [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (3) applying pattern '^(/.*)' to uri '/' [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (4) RewriteCond: input='app.domain.com' pattern='!^www.*' [NC] => matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (4) RewriteCond: input='app.domain.com' pattern='^app\.domain\.com$' [NC] => matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (4) RewriteCond: input='/' pattern='!^/app1/.*$' => matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (4) RewriteCond: input='/' pattern='!^.*\.ico$' [NC] => matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (2) rewrite '/' -> 'balancer://happcluster/app1/' [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (2) forcing proxy-throughput with balancer://happcluster/app1/ [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d73c0/initial] (1) go-ahead with proxy request proxy:balancer://happcluster/app1/ [OK] [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (2) init rewrite engine with requested uri /app1/login.jsp;jsessionid=F6D9765F6A737DB373D9C3AA60211B68.worker1 [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (3) applying pattern '^(/.*)' to uri '/app1/login.jsp;jsessionid=F6D9765F6A737DB373D9C3AA60211B68.worker1' [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (4) RewriteCond: input='app.domain.com' pattern='!^www.*' [NC] => matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (4) RewriteCond: input='app.domain.com' pattern='^app\.domain\.com$' [NC] => matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (4) RewriteCond: input='/app1/login.jsp;jsessionid=F6D9765F6A737DB373D9C3AA60211B68.worker1' pattern='!^/app1/.*$' => not-matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (3) applying pattern '^(/.*)' to uri '/app1/login.jsp;jsessionid=F6D9765F6A737DB373D9C3AA60211B68.worker1' [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (4) RewriteCond: input='app.domain.com' pattern='!^www.*' [NC] => matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (4) RewriteCond: input='app.domain.com' pattern='^app\.domain\.com$' [NC] => matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (4) RewriteCond: input='/app1/login.jsp;jsessionid=F6D9765F6A737DB373D9C3AA60211B68.worker1' pattern='!^/app1/.*$' => not-matched [app.domain.com/sid#2b0c5d2d4ef0][rid#2b0c5d0d53b0/initial] (1) pass through /app1/login.jsp;jsessionid=F6D9765F6A737DB373D9C3AA60211B68.worker1 

Y un fragment de mi access_log –

 "GET /app1/login.jsp HTTP/1.1" 200 607 "GET / HTTP/1.1" 302 - "GET /app1/login.jsp;jsessionid=F6D9765F6A737DB373D9C3AA60211B68.worker1 HTTP/1.1" 200 607 

Este tipo de cosas está condenada al fracaso, ya que Tomcat también integrará URLs auto-relacionadas en el HTML que produce. Hay un module de terceros para arreglar que, así, pero incluso el uso de reglas de reescritura es generalmente una señal de que está haciendo lo malo. La única técnica que realmente funciona es usar la misma URL en Apache y Tomcat. En este caso, solo averigüe cuáles son las URL de context de Tomcat y ProxyPass todas.

Estoy de acuerdo con Shane Madden que debe search mod_proxy_ajp en lugar de mod_jk. Es millas más fácil de configurar, hace exactamente lo mismo, y es parte de Apache, no una pieza separada.