]> granicus.if.org Git - apache/commitdiff
ProxyPassInherit directive
authorJim Jagielski <jim@apache.org>
Mon, 28 Jan 2013 13:58:24 +0000 (13:58 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 28 Jan 2013 13:58:24 +0000 (13:58 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1439404 13f79535-47bb-0310-9956-ffa450edef68

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

index 316918a028bee6e9654e3ce34ee9c6dd9b968d4a..1288423308649aedff15b9a37a8c6b761fbf06a8 100644 (file)
@@ -664,20 +664,40 @@ expressions</description>
     </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>
+    <description>Inherit proxy Balancers/Workers defined 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.4.4 and later.
         and later.</compatibility>
     <usage>
-        <p>This directive will cause the current server/vhost to "inherit" ProxyPass
+        <p>This directive will cause the current server/vhost to "inherit"
             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>
+            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 <directive module="mod_proxy">ProxyPassInherit</directive> also disables BalancerInherit.</p>
     </usage>
 </directivesynopsis>
 
index 66aff78734e6d5aa60bde7ebb9cb317a6e9f5175..e2d219ccc5afc35fb4682170a5c5c586a6f00f2c 100644 (file)
  * 20121222.1 (2.5.0-dev)  Add http_conformance to core_server_config,
  *                         add ap_has_cntrl()
  * 20121222.2 (2.5.0-dev)  Add ap_password_validate()
+ * 20121222.3 (2.5.0-dev)  Add ppinherit to proxy_server_conf
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20121222
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 2                   /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 3                   /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index b7623b34ed9dc70d71907827bc95d3b33c4a802b..8c5f94271e26d2a19d1675ed657f318e0ea662bd 100644 (file)
@@ -1162,6 +1162,8 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s)
     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;
@@ -1191,12 +1193,20 @@ static void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
     ps->inherit = (overrides->inherit_set == 0) ? base->inherit : overrides->inherit;
     ps->inherit_set = overrides->inherit_set || base->inherit_set;
 
-    ps->proxies = apr_array_append(p, base->proxies, overrides->proxies);
+    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);
-    if (ps->inherit) {
+    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);
     }
@@ -1911,6 +1921,16 @@ static const char *set_inherit(cmd_parms *parms, void *dummy, int flag)
     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;
@@ -2301,8 +2321,11 @@ static const command_rec proxy_cmds[] =
     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 ProxyPassed balancers and workers defined in the main server "
-     "(Not recommended if using the Balancer Manager)"),
+     "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 fc4514bd9ea16fed0429ac13efb0ad0a7ab3bee3..06f2de2110b7fb4d150003a721a964cb0236be57 100644 (file)
@@ -181,6 +181,8 @@ typedef struct {
     unsigned int inherit:1;
     unsigned int inherit_set:1;
     unsigned int bal_persist:1;
+    unsigned int ppinherit:1;
+    unsigned int ppinherit_set:1;
 } proxy_server_conf;