httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r109316 - /httpd/httpd/trunk/modules/proxy/mod_proxy.c /httpd/httpd/trunk/modules/proxy/mod_proxy.h /httpd/httpd/trunk/modules/proxy/proxy_util.c
Date Wed, 01 Dec 2004 08:44:13 GMT
Author: mturk
Date: Wed Dec  1 00:44:11 2004
New Revision: 109316

URL: http://svn.apache.org/viewcvs?view=rev&rev=109316
Log:
Add generic reverse proxy worker so that module-driven reverse proxying works. It is enabled
by default, but IMO it should be configurable like any other worker so we can limit the number
of outgoing connections.
Modified:
   httpd/httpd/trunk/modules/proxy/mod_proxy.c
   httpd/httpd/trunk/modules/proxy/mod_proxy.h
   httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/mod_proxy.c?view=diff&rev=109316&p1=httpd/httpd/trunk/modules/proxy/mod_proxy.c&r1=109315&p2=httpd/httpd/trunk/modules/proxy/mod_proxy.c&r2=109316
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c	(original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c	Wed Dec  1 00:44:11 2004
@@ -769,6 +769,7 @@
     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 @@
     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 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 @@
             /* 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;
     }
 }

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/mod_proxy.h?view=diff&rev=109316&p1=httpd/httpd/trunk/modules/proxy/mod_proxy.h&r1=109315&p2=httpd/httpd/trunk/modules/proxy/mod_proxy.h&r2=109316
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h	(original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h	Wed Dec  1 00:44:11 2004
@@ -131,6 +131,7 @@
     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;

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/proxy/proxy_util.c?view=diff&rev=109316&p1=httpd/httpd/trunk/modules/proxy/proxy_util.c&r1=109315&p2=httpd/httpd/trunk/modules/proxy/proxy_util.c&r2=109316
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c	(original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c	Wed Dec  1 00:44:11 2004
@@ -1188,13 +1188,30 @@
     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;
             }
         }

Mime
View raw message