You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Jean-Paul Abgrall <Je...@Phoenix.com> on 2000/08/13 08:16:54 UTC

ApJServMount /zone1 /tomcatZone1 problem

Using apache1.3.12, tomcat3.1

mod_jserv + Tomcat do not deal properly with rewritten URIs. 
With this mount point:
	ApJServMount /wdlcontext  ajpv12://localhost:8008/wdlcontext1.4.0
this request:
	/wdlcontext/wdlInstall?blabla
will fail because tomcat will only use the original URI passed by mod_jserv
instead of using the context set by mod_jserv. 

This is very problematic when using mod_rewrite.


A patch-candidate for Ajp12ConnectionHandler.java is at the end. 
Could somebody please review it?

thanks.

jpa


==== debug message before the fix ===========
==> /local/jakarta-tomcat/logs/tomcat.log <==
AJP: CP=wdlcontext1.4.0
AJP: context=null
AJP: servlet=wdlInstall
AJP: serverName=dev.phoenixnet.com
AJP: PI=null
AJP: PT=null
AJP: QS=null
AJP: RA=134.122.3.102
AJP: RH=
AJP: RU=null
AJP: AT=null
AJP: Meth=GET
AJP: URI: /wdlcontext/wdlInstall CP:wdlcontext1.4.0 LP: null
AJP: URI: /wdlcontext/wdlInstall CP:wdlcontext1.4.0 LP: null
AJP: serverName=jabgrall2
AJP: Server jvmRoute=null
Request: /wdlcontext/wdlInstall
Query: null
ProcessRequest: R( /wdlcontext/wdlInstall)

==== debug message after the fix ============
==> /local/jakarta-tomcat/logs/tomcat.log <==
AJP: CP=wdlcontext1.4.0
AJP: context=Ctx(/wdlcontext1.4.0,/local/ebetween/contexts/wdlcontext1.4.0)
AJP: servlet=wdlInstall
AJP: serverName=dev.phoenixnet.com
AJP: PI=null
AJP: PT=null
AJP: QS=null
AJP: RA=134.122.3.102
AJP: RH=
AJP: RU=null
AJP: AT=null
AJP: Meth=GET
AJP: URI: /wdlcontext/wdlInstall CP:wdlcontext1.4.0 LP: null
AJP: URI: /wdlcontext/wdlInstall CP:wdlcontext1.4.0 LP: /wdlInstall
AJP: serverName=jabgrall2
AJP: Server jvmRoute=null
Request: /wdlcontext/wdlInstall
Query: null
ProcessRequest: R( /wdlcontext1.4.0 + /wdlInstall)
After processing: R( /wdlcontext1.4.0 + /wdlInstall + null)


======== PATCH FOR AJPV12 context lookup fix =========
--- Ajp12ConnectionHandler.java Thu Apr  6 19:11:36 2000
+++ Ajp12ConnectionHandler.java.fix     Sat Aug 12 22:30:36 2000
@@ -224,6 +224,16 @@
                    
                    if( contextPath!= null )
                        context=contextM.getContext( contextPath );
+                   /* 
+                    * XXX jpa:200008122227
+                    * With this mount:
+                    *    ApJServMount /wdlcontext1.4.0
ajpv12://localhost:8008/wdlcontext1.4.0
+                    * mod_jserv will return 'wdlcontext1.4.0' as the
mountpoint (=context)
+                    *  instead of '/wdlcontext1.4.0'
+                    * So let's try to fix it by adding the 
+                    */
+                   if( context == null )
+                       context=contextM.getContext( "/" + contextPath ); 
                    if( doLog ) log("AJP: context=" + context );
                    
                    servletName = ajpin.readString(null);         //Servlet
@@ -264,10 +274,25 @@
                    requestURI = ajpin.readString("");             //request
uri
                    if( doLog ) log("AJP: URI: " + requestURI + " CP:" +
contextPath + " LP: " + lookupPath);
 
-                   // XXX don't set lookup path - problems with URL
rewriting.
-                   // need to be fixed.
-                   //          if(contextPath!=null && contextPath.length()
>0 )
-                   //              lookupPath=requestURI.substring(
contextPath.length() + 1 );
+                   /* 
+                    * XXX jpa:200008122227
+                    * With this rewrite rule: 
+                    *  RewriteRule ^(.*)/wdlzone/wdlInstall
$1/wdlcontext1.4.0/wdlInstall [PT]
+                    * and this mount point:
+                    *  ApJServMount /wdlcontext1.4.0
ajpv12://localhost:8008/wdlcontext1.4.0
+                    * and this context
+                    *    <Context path = "/wdlcontext1.4.0" docBase = "....
+                    * and this request
+                    *    /wdlzone/wdlInstall?blabla
+                    * The contextPath (after the above '/' fixup) is
'/wdlcontext1.4.0'
+                    *  and the uri is '/wdlzone/wdlInstall' 
+                    * the servlet name is 'wdlInstall'
+                    * So the lookupPath is is based on the position of the
servlet name.
+                    * Prior to the following fix, zones and contexts in
mounting points were
+                    *  irrelevant. Only the original uri was then used by
tomcat.
+                    */
+                   if(contextPath!=null && contextPath.length() >0 )
+                       lookupPath=requestURI.substring(
requestURI.indexOf(servletName)-1 );
                    if( doLog ) log("AJP: URI: " + requestURI + " CP:" +
contextPath + " LP: " + lookupPath);
                    
                    dummy = ajpin.readString(null);
//script filename