From c32a7e9db208fa9ae17724a8c6bb82e61f56ab67 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 30 Apr 2013 14:18:13 +0000 Subject: [PATCH] Merge r1387603, r1388029, r1420124, r1421288, r1421912, r1422943, r1422980, r1430575, r1439404 from trunk: 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 | 4 +++ docs/manual/mod/mod_proxy.xml | 38 ++++++++++++++++++++++++- include/ap_mmn.h | 3 +- modules/proxy/mod_proxy.c | 53 +++++++++++++++++++++++++++++++++-- modules/proxy/mod_proxy.h | 4 +++ 5 files changed, 97 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index bb43fe5fe4..81a5dc50c2 100644 --- 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] diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index 9e84f37c66..121470cbef 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -663,7 +663,43 @@ expressions normal restart/graceful state transitions.

- + + + 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 + BalancerInherit On|Off + BalancerInherit On + server configvirtual host + BalancerInherit is only available in Apache HTTP Server 2.5.0 + and later. + +

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.

+

The setting in the global server defines the default for all vhosts.

+
+
+ BalancerMember Add a member to a load balancing group diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 715acb6507..b054ab4d77 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -403,6 +403,7 @@ * 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" */ @@ -410,7 +411,7 @@ #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 diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index e16baa3daf..50416f4d01 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -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, diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index ca4bb65e31..77f211987d 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -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; -- 2.50.1