Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 39034 invoked from network); 2 Mar 2009 14:31:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Mar 2009 14:31:07 -0000 Received: (qmail 44762 invoked by uid 500); 2 Mar 2009 14:30:55 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 44624 invoked by uid 500); 2 Mar 2009 14:30:54 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 44613 invoked by uid 99); 2 Mar 2009 14:30:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2009 06:30:54 -0800 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [195.227.30.149] (HELO mailserver.kippdata.de) (195.227.30.149) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2009 14:30:46 +0000 Received: from [10.130.41.72] ([10.130.41.72]) by mailserver.kippdata.de (8.13.5/8.13.5) with ESMTP id n22EUPeQ027896 for ; Mon, 2 Mar 2009 15:30:25 +0100 (CET) Message-ID: <49ABED38.70009@kippdata.de> Date: Mon, 02 Mar 2009 15:29:12 +0100 From: Rainer Jung User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1b3pre) Gecko/20090223 Thunderbird/3.0b2 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: JkMount a different location References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 02.03.2009 03:21, Andres Riancho wrote: > List, > > I've search the Tomcat FAQ, but I haven't been able to find any > answers, so... here is my question... I have a JSP application > deployed in Tomcat inside the "/abc/" directory; and I want to be able > to access it from *two different locations* from Apache, for example, > when I access: "http://apache/abc/" and "http://apache/123/abc/". The > first JkMount is trivial: > > JkMount /abc ajp13_worker > JkMount /abc/* ajp13_worker > > And is working as expected, but for the second... I don't have the > slightest clue on how to do it... I tried mod_rewrite, but it seems > that it isn't possible to combine JkMount's and URL rewrites in a > successful way. Could anyone point me in the right direction? Thanks! > > I'm using Apache2, Tomcat6. I'll give an answer for Apache 2.2 and yes, this is missing in the documentation at the moment. For IIS there is a builtin rewrite feature in mod_jk, but not for httpd, because httpd can already do it on its own. Context rewriting for mod_jk and Apache httpd ============================================= Tested with httpd 2.2.11. You need to handle three things: 1) Rewrite the URL /xxx/something to /yyy/something before the request gets send to Tomcat 2) Change any redirects you get back from Tomcat, which point to locations /yyy/somethingelse, into location /xxx/somethingelse 3) Change pathes of cookies, which might get set by the application from /yyy to /xxx. The module mod_proxy allow sto do this via ProxyPass, ProxyPassReverse and ProxyPassReverseCookiePath directives. But you can't use mod_proxy and mod_jk for the same requests. The first directive can be replaced by some RewriteRule, the other two cases will be handled by dynamically changing response headers. So lets start with JkMount /yyy/* myworker and now: ad 1) RewriteRule ^/xxx/(.*)$ /yyy/$1 [PT] This will change any rquest /xxx/something into /yyy/something before passing it to mod_jk. ad 2) Header edit Location ^([^/]*//[^/]*)?/yyy/(.*)$ $1/xxx/$2 This changes Location headers, the headers used for signalling a redirect to the client. Any URL of the form "protocol://server:port/yyy/something" will be changed (yyy -> xxx), as well as URLs of the form "/yyy/something". Happy regular expression studying. ad 3) Header edit Set-Cookie "^(.*; Path=)/yyy([/;].*)?$" $1/xxx$2 This changes Set-Cookie headers, the headers used for setting a cookie. I hope you get the idea. In case your webapp puts self referential links into he response pages themselves, things get more complicated (or say: more expensive in terms of CPU cycles). Then you must parse the complete response pages to do search and replace. You can do that e.g. with mod_substitute or mod_sed or mod_proxy_html. It seems it would be nice, mod_jk had short hand notations for 1)-3). You can file an enhancement request in bugzilla for this, if you like. Regards, Rainer --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org