On 03/27/2006 05:15 PM, Jim Jagielski wrote: > > On Mar 23, 2006, at 9:59 AM, Plüm, Rüdiger, VIS wrote: > >> >> >>> -----Ursprüngliche Nachricht----- >>> Von: Jim Jagielski >>> >>>> >>>> I want to be able to use same balancer in multiple vhosts. >>>> >>> >>> This is actually that way by design, iirc. I've no >>> real issues with it being Vhost specific or inheritable. >>> So if others think it's worthwhile having the above >>> functionality, I'm +1 for it and would work on something >>> to implement that. >> >> >> +1 makes sense. >> > > Something like this maybe? Of course, since it's inherited, > the balancer shows up twice in the balancer-manager, but > maybe that make sense :) > > Index: modules/proxy/mod_proxy.c > =================================================================== > --- modules/proxy/mod_proxy.c (revision 389138) > +++ modules/proxy/mod_proxy.c (working copy) > @@ -1625,6 +1625,19 @@ > conf = ap_set_config_vectors(cmd->server, new_dir_conf, cmd->path, > &proxy_module, cmd->pool); > + if (strncasecmp(cmd->path, "balancer:", 9) == 0) { > + proxy_server_conf *sconf = > + (proxy_server_conf *) ap_get_module_config(cmd->server- >>module_config, &proxy_module); > + proxy_balancer *balancer = ap_proxy_get_balancer(cmd->pool, > sconf, cmd->path); > + if (!balancer) { > + const char *err = ap_proxy_add_balancer(&balancer, > + cmd->pool, > + sconf, cmd->path); > + if (err) > + return apr_pstrcat(cmd->temp_pool, "<Proxy> ", err, > NULL); > + } > + } > + > errmsg = ap_walk_config(cmd->directive->first_child, cmd, > new_dir_conf); > if (errmsg != NULL) > return errmsg; >
Sorry for being somewhat lost, but currently I struggle to understand what this patch actually does. So I try to explain what I understood so far. Please correct me if I am wrong :-). If the path of a <Proxy block starts with balancer: and this balancer isn't already in the server config you add it. The same would happen with todays code provided that the <Proxy block contains at least one BalancerMember directive (an assumption which seems to make sense to me). Currently I do not see how this changes the following configuration problem: <Proxy balancer://fill> BalancerMember http://server1:80 route=server1 BalancerMember http://server2:80 route=server2 </Proxy> <VirtualHost *> ... ProxyPass /path balancer://fill/ stickysession=Sticky </VirtualHost> Because with old and new code a balancer called fill with 2 members gets added to the main server config. The ProxyPass directive in the virtualhost causes another balancer called fill added to the (then empty) conf->balancers array of this virtual host configuration. Afterwards both configurations get merged and we have two balancers called fill in the merged array conf->balancers for this virtual host: One that is inherited from the main server with 2 members (and actually is the same balancer as the one in the main server) and one empty that got created by ProxyPass inside the virtual host. Actually the configuration works because during request processing ap_proxy_get_balancer starts searching at the beginning of the conf->balancers array and thus finds the non empty balancer. If I go somewhat further with my thoughts and have a look at the following configuration <Proxy balancer://fill> BalancerMember http://server1:80 route=server1 BalancerMember http://server2:80 route=server2 </Proxy> <VirtualHost A> ... ProxyPass /path balancer://fill/ stickysession=Sticky </VirtualHost> <VirtualHost B> ... ProxyPass /path balancer://fill/ stickysession=Sticky </VirtualHost> Then according to my thoughts virtualhost A and B would effectively share the balancer from the main server. As far as I understood this is a situation you wanted to avoid. But as said I am not an expert on these configuration issue, so this maybe all wrong :-). If yes, please give me a hint where I missed the train. Regards Rüdiger