]> granicus.if.org Git - apache/commitdiff
Now let things like
authorJim Jagielski <jim@apache.org>
Tue, 29 Jan 2008 14:26:20 +0000 (14:26 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 29 Jan 2008 14:26:20 +0000 (14:26 +0000)
   ProxyPassReverse /foo balancer://bar

work "as expected" :) :)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@616335 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index 56047eef015a468ffad6a0701e39d821a5c52b9e..90337de1afd37dca5fd3eadfbdf55155067a66fa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) ProxyPassReverse is now balancer aware. [Jim Jagielski]
+
   *) rotatelogs: Don't leak memory when reopening the logfile.
      PR 40183 [Ruediger Pluem, Takashi Sato <serai lans-tv.com>]
 
index edf020cee0836caa9d3de264c88805cd92b1b147..410cb0523d19e17104c1f3c928d9c8e8aaf503b2 100644 (file)
@@ -1063,8 +1063,54 @@ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
         ent = (struct proxy_alias *)conf->raliases->elts;
     }
     for (i = 0; i < conf->raliases->nelts; i++) {
-        l2 = strlen(ent[i].real);
-        if (l1 >= l2 && strncasecmp(ent[i].real, url, l2) == 0) {
+        proxy_server_conf *sconf = (proxy_server_conf *)
+            ap_get_module_config(r->server->module_config, &proxy_module);
+        proxy_balancer *balancer;
+        const char *real;
+        real = ent[i].real;
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "ppr: real: %s", real);
+        /*
+         * First check if mapping against a balancer and see
+         * if we have such a entity. If so, then we need to
+         * find the particulars of the actual worker which may
+         * or may not be the right one... basically, we need
+         * to find which member actually handled this request.
+         */
+        if ((strncasecmp(real, "balancer:", 9) == 0) &&
+            (balancer = ap_proxy_get_balancer(r->pool, sconf, real))) {
+            int n;
+            proxy_worker *worker;
+            worker = (proxy_worker *)balancer->workers->elts;
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "ppr: checking balancer: %s",
+                         balancer->name);
+            for (n = 0; n < balancer->workers->nelts; n++) {
+                if (worker->port) {
+                    u = apr_psprintf(r->pool, "%s://%s:%d/", worker->scheme,
+                                     worker->hostname, worker->port);
+                }
+                else {
+                    u = apr_psprintf(r->pool, "%s://%s/", worker->scheme,
+                                     worker->hostname);
+                }
+                ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "ppr: matching member (%s) and URL (%s)",
+                         u, url);
+
+                l2 = strlen(u);
+                if (l1 >= l2 && strncasecmp(u, url, l2) == 0) {
+                    u = apr_pstrcat(r->pool, ent[i].fake, &url[l2], NULL);
+                    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "ppr: matched member (%s)", u);
+                    return ap_construct_url(r->pool, u, r);
+                }
+                worker++;
+            }
+        }
+
+        l2 = strlen(real);
+        if (l1 >= l2 && strncasecmp(real, url, l2) == 0) {
             u = apr_pstrcat(r->pool, ent[i].fake, &url[l2], NULL);
             return ap_construct_url(r->pool, u, r);
         }