]> granicus.if.org Git - apache/commitdiff
Merge r1387603, r1388029, r1420124, r1421288, r1421912, r1422943, r1422980, r1430575...
authorJim Jagielski <jim@apache.org>
Tue, 30 Apr 2013 14:18:13 +0000 (14:18 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 30 Apr 2013 14:18:13 +0000 (14:18 +0000)
wtf are we doing merging in these from the parent??
These are server specific!

OK, enable/allow previous broken, bad behavior iff the user
really, really wants it. And warn that b-m isn't recommended
in those cases.

rjung's suggestions...

inherit inherit

Use inherit_set to let the global server set
the default for all vhosts.

Otherwise inherit would need to be disabled
redundantly in each vhost.

restrict inherit control to those fields that "require" it...

Redfine - we are just worried about balancers and workers, so have the directive clear about that.

Naming

ProxyPassInherit directive
Submitted by: jim, rjung, jim, jim, jim, jim
Reviewed/backported by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1477649 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_proxy.xml
include/ap_mmn.h
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h

diff --git a/CHANGES b/CHANGES
index bb43fe5fe4dbbbc84eebc66329e0f3cd7301e34b..81a5dc50c255a86baf4346d87eb42ec759c7a55b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 
 Changes with Apache 2.4.5
 
+  *) mod_proxy: Add BalancerInherit and ProxyPassInherit to control
+     whether Proxy Balancers and Workers are inherited by vhosts
+     (default is On). [Jim Jagielski]
+
   *) mod_authnz_ldap: Allow using exec: calls to obtain LDAP bind
      password.  [Daniel Ruggeri]
 
index 9e84f37c66427d1133915b09427038b59f72b67c..121470cbefa0ef7dcfa9b5d79fb13e90868e2944 100644 (file)
@@ -663,7 +663,43 @@ expressions</description>
         normal restart/graceful state transitions.</p>
     </usage>
 </directivesynopsis>
-    
+
+<directivesynopsis>
+    <name>ProxyPassInherit</name>
+    <description>Inherit ProxyPass directives defined from the main server</description>
+    <syntax>ProxyPassInherit On|Off</syntax>
+    <default>ProxyPassInherit On</default>
+    <contextlist><context>server config</context><context>virtual host</context></contextlist>
+    <compatibility>ProxyPassInherit is only available in Apache HTTP Server 2.5.0 and later.
+        and later.</compatibility>
+    <usage>
+        <p>This directive will cause the current server/vhost to "inherit"
+            <directive module="mod_proxy">ProxyPass</directive>
+            directives defined in the main server. This can cause issues and
+            inconsistent behavior if using the Balancer Manager for dynamic changes
+            and so should be disabled if using that feature.</p>
+        <p>The setting in the global server defines the default for all vhosts.</p>
+        <p>Disabling ProxyPassInherit also disables <directive module="mod_proxy">BalancerInherit</directive>.</p>
+    </usage>
+</directivesynopsis>
+
+<directivesynopsis>
+    <name>BalancerInherit</name>
+    <description>Inherit ProxyPassed Balancers/Workers from the main server</description>
+    <syntax>BalancerInherit On|Off</syntax>
+    <default>BalancerInherit On</default>
+    <contextlist><context>server config</context><context>virtual host</context></contextlist>
+    <compatibility>BalancerInherit is only available in Apache HTTP Server 2.5.0
+        and later.</compatibility>
+    <usage>
+        <p>This directive will cause the current server/vhost to "inherit" ProxyPass
+            Balancers and Workers defined in the main server. This can cause issues and
+            inconsistent behavior if using the Balancer Manager and so should be disabled
+            if using that feature.</p>
+        <p>The setting in the global server defines the default for all vhosts.</p>
+    </usage>
+</directivesynopsis>
+
 <directivesynopsis>
     <name>BalancerMember</name>
     <description>Add a member to a load balancing group</description>
index 715acb6507764f060a0d54e22c81bd2b324de7cd..b054ab4d77e21e6e807a34ef3a05e09e85681aff 100644 (file)
  * 20120211.11 (2.4.4-dev) Add ap_bin2hex()
  * 20120211.12 (2.4.5-dev)  Add ap_remove_input|output_filter_byhandle()
  * 20120211.13 (2.4.5-dev)  Add ap_get_exec_line
+ * 20120211.14 (2.4.5-dev)  Add ppinherit and inherit to proxy_server_conf
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20120211
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 13                   /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 14                   /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index e16baa3daf6663d7c5951a3029e0dae97775bfd8..50416f4d018b1fafd1a57cadb1f2ddf512d3891e 100644 (file)
@@ -1168,6 +1168,10 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s)
     ps->req = 0;
     ps->max_balancers = 0;
     ps->bal_persist = 0;
+    ps->inherit = 1;
+    ps->inherit_set = 0;
+    ps->ppinherit = 1;
+    ps->ppinherit_set = 0;
     ps->bgrowth = 5;
     ps->bgrowth_set = 0;
     ps->req_set = 0;
@@ -1194,13 +1198,30 @@ static void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
     proxy_server_conf *base = (proxy_server_conf *) basev;
     proxy_server_conf *overrides = (proxy_server_conf *) overridesv;
 
-    ps->proxies = apr_array_append(p, base->proxies, overrides->proxies);
+    ps->inherit = (overrides->inherit_set == 0) ? base->inherit : overrides->inherit;
+    ps->inherit_set = overrides->inherit_set || base->inherit_set;
+
+    ps->ppinherit = (overrides->ppinherit_set == 0) ? base->ppinherit : overrides->ppinherit;
+    ps->ppinherit_set = overrides->ppinherit_set || base->ppinherit_set;
+
+    if (ps->ppinherit) {
+        ps->proxies = apr_array_append(p, base->proxies, overrides->proxies);
+    }
+    else {
+        ps->proxies = overrides->proxies;
+    }
     ps->sec_proxy = apr_array_append(p, base->sec_proxy, overrides->sec_proxy);
     ps->aliases = apr_array_append(p, base->aliases, overrides->aliases);
     ps->noproxies = apr_array_append(p, base->noproxies, overrides->noproxies);
     ps->dirconn = apr_array_append(p, base->dirconn, overrides->dirconn);
-    ps->workers = apr_array_append(p, base->workers, overrides->workers);
-    ps->balancers = apr_array_append(p, base->balancers, overrides->balancers);
+    if (ps->inherit || ps->ppinherit) {
+        ps->workers = apr_array_append(p, base->workers, overrides->workers);
+        ps->balancers = apr_array_append(p, base->balancers, overrides->balancers);
+    }
+    else {
+        ps->workers = overrides->workers;
+        ps->balancers = overrides->balancers;
+    }
     ps->forward = overrides->forward ? overrides->forward : base->forward;
     ps->reverse = overrides->reverse ? overrides->reverse : base->reverse;
 
@@ -1898,6 +1919,26 @@ static const char *set_persist(cmd_parms *parms, void *dummy, int flag)
     return NULL;
 }
 
+static const char *set_inherit(cmd_parms *parms, void *dummy, int flag)
+{
+    proxy_server_conf *psf =
+    ap_get_module_config(parms->server->module_config, &proxy_module);
+
+    psf->inherit = flag;
+    psf->inherit_set = 1;
+    return NULL;
+}
+
+static const char *set_ppinherit(cmd_parms *parms, void *dummy, int flag)
+{
+    proxy_server_conf *psf =
+    ap_get_module_config(parms->server->module_config, &proxy_module);
+
+    psf->ppinherit = flag;
+    psf->ppinherit_set = 1;
+    return NULL;
+}
+
 static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
 {
     server_rec *s = cmd->server;
@@ -2287,6 +2328,12 @@ static const command_rec proxy_cmds[] =
      "Number of additional Balancers that can be added post-config"),
     AP_INIT_FLAG("BalancerPersist", set_persist, NULL, RSRC_CONF,
      "on if the balancer should persist changes on reboot/restart made via the Balancer Manager"),
+    AP_INIT_FLAG("BalancerInherit", set_inherit, NULL, RSRC_CONF,
+     "on if this server should inherit Balancers and Workers defined in the main server "
+     "(Not recommended if using the Balancer Manager for dynamic changes)"),
+    AP_INIT_FLAG("ProxyPassInherit", set_ppinherit, NULL, RSRC_CONF,
+     "on if this server should inherit all ProxyPass directives defined in the main server "
+     "(Not recommended if using the Balancer Manager for dynamic changes)"),
     AP_INIT_TAKE1("ProxyStatus", set_status_opt, NULL, RSRC_CONF,
      "Configure Status: proxy status to one of: on | off | full"),
     AP_INIT_RAW_ARGS("ProxySet", set_proxy_param, NULL, RSRC_CONF|ACCESS_CONF,
index ca4bb65e3142acede845458499d0d32969f4fe30..77f211987d383797ad72031341d7a8713046b31f 100644 (file)
@@ -179,6 +179,10 @@ typedef struct {
     unsigned int source_address_set:1;
     unsigned int bgrowth_set:1;
     unsigned int bal_persist:1;
+    unsigned int inherit:1;
+    unsigned int inherit_set:1;
+    unsigned int ppinherit:1;
+    unsigned int ppinherit_set:1;
 } proxy_server_conf;