]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
make mod_rewrite and mod_proxy UDS work together...
authorJim Jagielski <jim@apache.org>
Wed, 22 Jan 2014 14:54:21 +0000 (14:54 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 22 Jan 2014 14:54:21 +0000 (14:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1560367 13f79535-47bb-0310-9956-ffa450edef68

docs/log-message-tags/next-number
modules/mappers/mod_rewrite.c
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/proxy_util.c

index c882b49a4f5e01c984b97c88a4a13034778aa5da..4412be74f3006ebd1626615cf35e2e19d459c5b9 100644 (file)
@@ -1 +1 @@
-2597
+2598
index a46e2458b2dea894f418e78489fa49fb62106533..d736187715e23d0987d5a18b9cb70e1294f32d61 100644 (file)
@@ -4142,6 +4142,7 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
                     r->filename));
 
         r->filename = apr_pstrcat(r->pool, "proxy:", r->filename, NULL);
+        apr_table_setn(r->notes, "rewrite-proxy", "1");
         return 1;
     }
 
index 089135730f8f787771e3d20adc3d6e660d129f78..9d7c92fd58d81f9a8987c472abd835f3e28a148c 100644 (file)
@@ -2618,6 +2618,8 @@ static void child_init(apr_pool_t *p, server_rec *s)
                 ap_proxy_hashfunc(conf->forward->s->name, PROXY_HASHFUNC_FNV);
             /* Do not disable worker in case of errors */
             conf->forward->s->status |= PROXY_WORKER_IGNORE_ERRORS;
+            /* Mark as the "generic" worker */
+            conf->forward->s->status |= PROXY_WORKER_GENERIC;
             ap_proxy_initialize_worker(conf->forward, s, conf->pool);
             /* Disable address cache for generic forward worker */
             conf->forward->s->is_address_reusable = 0;
@@ -2633,6 +2635,8 @@ static void child_init(apr_pool_t *p, server_rec *s)
                 ap_proxy_hashfunc(reverse->s->name, PROXY_HASHFUNC_FNV);
             /* Do not disable worker in case of errors */
             reverse->s->status |= PROXY_WORKER_IGNORE_ERRORS;
+            /* Mark as the "generic" worker */
+            reverse->s->status |= PROXY_WORKER_GENERIC;
             conf->reverse = reverse;
             ap_proxy_initialize_worker(conf->reverse, s, conf->pool);
             /* Disable address cache for generic reverse worker */
index cc7fb02d2065b9f9c9eaa507d90e76714f50f4bc..b99ee17b90d8a5cf6ab4bd34945e9e6de8d09e39 100644 (file)
@@ -274,6 +274,7 @@ struct proxy_conn_pool {
 #define PROXY_WORKER_INITIALIZED    0x0001
 #define PROXY_WORKER_IGNORE_ERRORS  0x0002
 #define PROXY_WORKER_DRAIN          0x0004
+#define PROXY_WORKER_GENERIC        0x0008
 #define PROXY_WORKER_IN_SHUTDOWN    0x0010
 #define PROXY_WORKER_DISABLED       0x0020
 #define PROXY_WORKER_STOPPED        0x0040
@@ -285,6 +286,7 @@ struct proxy_conn_pool {
 #define PROXY_WORKER_INITIALIZED_FLAG    'O'
 #define PROXY_WORKER_IGNORE_ERRORS_FLAG  'I'
 #define PROXY_WORKER_DRAIN_FLAG          'N'
+#define PROXY_WORKER_GENERIC_FLAG        'G'
 #define PROXY_WORKER_IN_SHUTDOWN_FLAG    'U'
 #define PROXY_WORKER_DISABLED_FLAG       'D'
 #define PROXY_WORKER_STOPPED_FLAG        'S'
@@ -305,6 +307,8 @@ PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
 
 #define PROXY_WORKER_IS_DRAINING(f)   ( (f)->s->status &  PROXY_WORKER_DRAIN )
 
+#define PROXY_WORKER_IS_GENERIC(f)   ( (f)->s->status &  PROXY_WORKER_GENERIC )
+
 /* default worker retry timeout in seconds */
 #define PROXY_WORKER_DEFAULT_RETRY    60
 
index f67e0a7ae2c4ae43ee77f4920df5df900fc85dc5..79e30708799338c1a9e81f61e529066dc3237a1d 100644 (file)
@@ -1927,11 +1927,14 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
             }
         }
         else if (r->proxyreq == PROXYREQ_REVERSE) {
+            char *ptr;
+            const char *ptr2;
             if (conf->reverse) {
                 ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
                               "*: found reverse proxy worker for %s", *url);
                 *balancer = NULL;
                 *worker = conf->reverse;
+                *(*worker)->s->uds_path = '\0';
                 access_status = OK;
                 /*
                  * The reverse worker does not keep connections alive, so
@@ -1939,6 +1942,30 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
                  * regarding the Connection header in the request.
                  */
                 apr_table_setn(r->subprocess_env, "proxy-nokeepalive", "1");
+                /*
+                 * In the case of the generic reverse proxy, we need to see if we
+                 * were passed a UDS url (eg: from mod_proxy) and adjust uds_path
+                 * as required.
+                 */
+                if (apr_table_get(r->notes, "rewrite-proxy") &&
+                    (ptr2 = ap_strstr_c(r->filename, "unix:")) &&
+                    (ptr = ap_strchr(r->filename, '|'))) {
+                    apr_uri_t urisock;
+                    apr_status_t rv;
+                    *ptr = '\0';
+                    rv = apr_uri_parse(r->pool, ptr2, &urisock);
+                    if (rv == APR_SUCCESS) {
+                        char *sockpath = ap_runtime_dir_relative(r->pool, urisock.path);;
+                        if (PROXY_STRNCPY((*worker)->s->uds_path, sockpath) != APR_SUCCESS) {
+                            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02597)
+                            "worker uds path (%s) too long", sockpath);
+                        }
+                        r->filename = ptr+1;    /* so we get the scheme for the uds */
+                    }
+                    else {
+                        *ptr = '|';
+                    }
+                }
             }
         }
     }
@@ -2120,7 +2147,6 @@ PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
         (*conn)->uds_path = NULL;
     }
 
-
     return OK;
 }