In httpd-2.0, mod_dir uses ap_internal_fast_redirect once it has found an appropriate file from the DirectoryIndex list. This change makes it impossible to use mod_rewrite's proxypass feature on an index file. mod_dir finds the file, but returns its source instead of the output of the proxypass. The first patch "mod_dir-proxyfix.diff" reverts mod_dir back to its old behavior, which is to start up an entirely new subrequest once it finds the proper index file.

That change gets httpd-2.0 back to 1.3.27's behavior, which itself has another somewhat related bug. The second attachment "mod_rewrite+mod_dir-proxyfix.diff" is basically the same patch I posted to bug 14648, forward ported to 2.0.43. This patch allows mod_rewrite to do proxy-substitutions in subrequests. This fixes a bug which causes mod_rewrite-based proxypass directives to work differently from things setup directly in mod_proxy.

--
Mike Cramer
http://www.webkist.com/


diff --recursive -buB httpd-2.0.43/modules/mappers/mod_dir.c 
httpd-2.0.43-mrc/modules/mappers/mod_dir.c
--- httpd-2.0.43/modules/mappers/mod_dir.c      Thu May 16 01:20:46 2002
+++ httpd-2.0.43-mrc/modules/mappers/mod_dir.c  Mon Dec  2 14:19:26 2002
@@ -202,7 +202,15 @@
 
         /* XXX: (filetype == APR_REG) - we can't use a non-file index??? */
         if (rr->status == HTTP_OK && rr->finfo.filetype == APR_REG) {
-            ap_internal_fast_redirect(rr, r);
+            char *new_uri = ap_escape_uri(r->pool, rr->uri);
+
+            if (rr->args != NULL)
+                new_uri = apr_pstrcat(r->pool, new_uri, "?", rr->args, NULL);
+            else if (r->args != NULL)
+                new_uri = apr_pstrcat(r->pool, new_uri, "?", r->args, NULL);
+
+            ap_destroy_sub_req(rr);
+            ap_internal_redirect(new_uri, r);
             return OK;
         }
             
diff --recursive -buB httpd-2.0.43/modules/mappers/mod_dir.c 
httpd-2.0.43-1.3fix/modules/mappers/mod_dir.c
--- httpd-2.0.43/modules/mappers/mod_dir.c      Thu May 16 01:20:46 2002
+++ httpd-2.0.43-1.3fix/modules/mappers/mod_dir.c       Mon Dec  2 14:48:49 2002
@@ -198,7 +198,7 @@
             name_ptr = apr_pstrcat(r->pool, name_ptr, "?", r->args, NULL);
         }
 
-        rr = ap_sub_req_lookup_uri(name_ptr, r, NULL);
+        rr = ap_sub_req_lookup_file(name_ptr, r, NULL);
 
         /* XXX: (filetype == APR_REG) - we can't use a non-file index??? */
         if (rr->status == HTTP_OK && rr->finfo.filetype == APR_REG) {
diff --recursive -buB httpd-2.0.43/modules/mappers/mod_rewrite.c 
httpd-2.0.43-1.3fix/modules/mappers/mod_rewrite.c
--- httpd-2.0.43/modules/mappers/mod_rewrite.c  Fri Aug 30 00:47:57 2002
+++ httpd-2.0.43-1.3fix/modules/mappers/mod_rewrite.c   Mon Dec  2 14:48:34 2002
@@ -1707,7 +1707,6 @@
          */
         if (r->main != NULL &&
             (p->flags & RULEFLAG_IGNOREONSUBREQ ||
-             p->flags & RULEFLAG_PROXY          ||
              p->flags & RULEFLAG_FORCEREDIRECT    )) {
             continue;
         }


Reply via email to