Hi,

I have found out that if you use ProxyPassMatch with regexp and "$1" (see PR 43513 and PR 54973), the right proxy_worker is not used and "reverse" proxy_worker is used instead. The result is situation where no options like "timeout" can be set in this case.

The real problem here is that proxy_worker is chosen according to its name which contains "$1" sequence in our case.

I have found out that there is already patch fixing ProxyPassMatch behaviour with "$1" in PR 43513. I have rebased the patch for trunk and changed its style a bit.

The patch strips everything after "$", so it for example changes the name of proxy_worker from "http://127.0.0.1/cgi-bin/$1"; to "http://127.0.0.1/cgi-bin/";. Later when request arrives, proper proxy_worker is chosen. Without this change, proxy_worker's name with "$1" would be compared against real request URL, but real request URL does not contain this "$1" sequence and therefore this correct proxy_worker wouldn't be chosen.

Do you see any problems with this patch?

Regards,
Jan Kaluza
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
index 96f3230..f58f4c4 100644
--- a/modules/proxy/mod_proxy.c
+++ b/modules/proxy/mod_proxy.c
@@ -1533,8 +1533,26 @@ static const char *
         new->balancer = balancer;
     }
     else {
-        proxy_worker *worker = ap_proxy_get_worker(cmd->temp_pool, NULL, conf, r);
+        proxy_worker *worker;
         int reuse = 0;
+        /* When the scheme or the hostname contains '$', skip.
+         * When the path contains '$', use a path before '$' for the worker
+         * name. */
+        if (use_regex) {
+            char *r2 = apr_pstrdup(cmd->temp_pool, r);
+            char *tmp_css = ap_strstr(r2, "://");
+            if (tmp_css != NULL) {
+                char *tmp_dollar = ap_strchr(r2, '$');
+                if (tmp_dollar != NULL) {
+                    char *tmp_slash = ap_strchr(&tmp_css[3], '/');
+                    if (tmp_slash != NULL && tmp_slash <= tmp_dollar) {
+                        *tmp_dollar = '\0';
+                    }
+                }
+            }
+            r = r2;
+        }
+        worker = ap_proxy_get_worker(cmd->temp_pool, NULL, conf, r);
         if (!worker) {
             const char *err = ap_proxy_define_worker(cmd->pool, &worker, NULL, conf, r, 0);
             if (err)

Reply via email to