]> granicus.if.org Git - apache/commitdiff
Add generic reverse proxy worker so that module-driven reverse proxying works. It...
authorMladen Turk <mturk@apache.org>
Wed, 1 Dec 2004 08:44:11 +0000 (08:44 +0000)
committerMladen Turk <mturk@apache.org>
Wed, 1 Dec 2004 08:44:11 +0000 (08:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@109316 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/proxy_util.c

index 01d804f919ee59452b68f393a193c80319da8640..0804d3bff7110be9d49c80ed22b1eb10580db019 100644 (file)
@@ -769,6 +769,7 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s)
     ps->workers = apr_array_make(p, 10, sizeof(proxy_worker));
     ps->balancers = apr_array_make(p, 10, sizeof(proxy_balancer));
     ps->forward = NULL;
+    ps->reverse = NULL;
     ps->domain = NULL;
     ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */
     ps->viaopt_set = 0; /* 0 means default */
@@ -814,6 +815,7 @@ static void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
     ps->workers = apr_array_append(p, base->workers, overrides->workers);
     ps->balancers = apr_array_append(p, base->balancers, overrides->balancers);
     ps->forward = overrides->forward ? overrides->forward : base->forward;
+    ps->reverse = overrides->reverse ? overrides->reverse : base->reverse;
 
     ps->domain = (overrides->domain == NULL) ? base->domain : overrides->domain;
     ps->viaopt = (overrides->viaopt_set == 0) ? base->viaopt : overrides->viaopt;
@@ -1754,6 +1756,7 @@ static int proxy_status_hook(request_rec *r, int flags)
 
 static void child_init(apr_pool_t *p, server_rec *s)
 {
+    proxy_worker *reverse = NULL;
     
     while (s) {
         void *sconf = s->module_config;
@@ -1776,6 +1779,17 @@ static void child_init(apr_pool_t *p, server_rec *s)
             /* Do not disable worker in case of errors */
             conf->forward->s->status |= PROXY_WORKER_IGNORE_ERRORS;
         }
+        if (!reverse) {
+            reverse = ap_proxy_create_worker(p);
+            reverse->name     = "proxy:reverse";
+            reverse->hostname = "*";
+            reverse->scheme   = "*";
+            ap_proxy_initialize_worker_share(conf, reverse, s);
+            ap_proxy_initialize_worker(reverse, s);
+            /* Do not disable worker in case of errors */
+            reverse->s->status |= PROXY_WORKER_IGNORE_ERRORS;
+        }
+        conf->reverse = reverse;
         s = s->next;
     }
 }
index 535a70af015b7ead467d02642719b9d49ca0f710..6f34ca5f145009e4fcebbe12e29edc952265496d 100644 (file)
@@ -131,6 +131,7 @@ typedef struct {
     apr_array_header_t *workers;
     apr_array_header_t *balancers;
     proxy_worker       *forward;    /* forward proxy worker */
+    proxy_worker       *reverse;    /* reverse "module-driven" proxy worker */
     const char *domain;     /* domain name to use in absence of a domain name in the request */
     int req;                /* true if proxy requests are enabled */
     char req_set;
index e2410e7b0d614660f3c9443308365f62a85c8eb2..884c7ec0d4a4673a38cf0cf9530a18c4a71f6734 100644 (file)
@@ -1188,16 +1188,33 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
     if (access_status == DECLINED && *balancer == NULL) {
         *worker = ap_proxy_get_worker(r->pool, conf, *url);
         if (*worker) {
+            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                          "proxy: %s: found worker %s for %s",
+                           (*worker)->scheme, (*worker)->name, *url);
+
             *balancer = NULL;
             access_status = OK;
         }
         else if (r->proxyreq == PROXYREQ_PROXY) {
             if (conf->forward) {
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                              "proxy: *: found forward proxy worker for %s",
+                               *url);
                 *balancer = NULL;
                 *worker = conf->forward;
                 access_status = OK;
             }
         }
+        else if (r->proxyreq == PROXYREQ_REVERSE) {
+            if (conf->reverse) {
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                              "proxy: *: found reverse proxy worker for %s",
+                               *url);
+                *balancer = NULL;
+                *worker = conf->reverse;
+                access_status = OK;
+            }
+        }
     }
     else if (access_status == DECLINED && balancer != NULL) {
         /* All the workers are busy */