From 0d13f604c16322e6371edf336b1a90eeaa7433fa Mon Sep 17 00:00:00 2001
From: Jim Jagielski
Date: Mon, 28 Jan 2013 13:58:24 +0000
Subject: [PATCH] ProxyPassInherit directive
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1439404 13f79535-47bb-0310-9956-ffa450edef68
---
docs/manual/mod/mod_proxy.xml | 28 ++++++++++++++++++++++++----
include/ap_mmn.h | 3 ++-
modules/proxy/mod_proxy.c | 31 +++++++++++++++++++++++++++----
modules/proxy/mod_proxy.h | 2 ++
4 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml
index 316918a028..1288423308 100644
--- a/docs/manual/mod/mod_proxy.xml
+++ b/docs/manual/mod/mod_proxy.xml
@@ -664,20 +664,40 @@ expressions
+
+ ProxyPassInherit
+ Inherit ProxyPass directives defined from the main server
+ ProxyPassInherit On|Off
+ ProxyPassInherit On
+ server configvirtual host
+ ProxyPassInherit is only available in Apache HTTP Server 2.5.0 and later.
+ and later.
+
+ This directive will cause the current server/vhost to "inherit"
+ ProxyPass
+ 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.
+ The setting in the global server defines the default for all vhosts.
+ Disabling ProxyPassInherit also disables BalancerInherit.
+
+
+
BalancerInherit
- Inherit ProxyPassed Balancers/Workers from the main server
+ Inherit proxy Balancers/Workers defined from the main server
BalancerInherit On|Off
BalancerInherit On
server configvirtual host
BalancerInherit is only available in Apache HTTP Server 2.4.4 and later.
and later.
- This directive will cause the current server/vhost to "inherit" ProxyPass
+
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.
+ inconsistent behavior if using the Balancer Manager for dynamic changes
+ and so should be disabled if using that feature.
The setting in the global server defines the default for all vhosts.
+ Disabling ProxyPassInherit also disables BalancerInherit.
diff --git a/include/ap_mmn.h b/include/ap_mmn.h
index 66aff78734..e2d219ccc5 100644
--- a/include/ap_mmn.h
+++ b/include/ap_mmn.h
@@ -413,6 +413,7 @@
* 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" */
@@ -420,7 +421,7 @@
#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
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
index b7623b34ed..8c5f94271e 100644
--- a/modules/proxy/mod_proxy.c
+++ b/modules/proxy/mod_proxy.c
@@ -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,
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h
index fc4514bd9e..06f2de2110 100644
--- a/modules/proxy/mod_proxy.h
+++ b/modules/proxy/mod_proxy.h
@@ -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;
--
2.49.0