Bug 53736 - /balancer-manager doesn't save runtime adjusted settings
Summary: /balancer-manager doesn't save runtime adjusted settings
Status: RESOLVED LATER
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy_balancer (show other bugs)
Version: 2.2.16
Hardware: PC Linux
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: MassUpdate, PatchAvailable
Depends on:
Blocks:
 
Reported: 2012-08-17 22:34 UTC by bpkroth
Modified: 2018-11-07 21:08 UTC (History)
0 users



Attachments
relevant vhost confs (3.86 KB, application/octet-stream)
2012-08-17 22:34 UTC, bpkroth
Details
example /balancer-manager output (1.83 KB, text/plain)
2012-08-17 22:35 UTC, bpkroth
Details
mod_proxy_balancer-manager_ipv6_backends.patch (1.47 KB, patch)
2013-02-09 00:02 UTC, bpkroth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bpkroth 2012-08-17 22:34:43 UTC
Created attachment 29249 [details]
relevant vhost confs

I'm using mod_proxy_balancer to balance requests across different backends for some vhosts in a hosting environment.  Currently there's actually only one vhost that uses the balancer.  All others use a simple ProxyPass directive to a single backend host in their VirtualHost configs.

I would like to be able to use the /balancer-manager on the balancer vhost (really the proxy for it) to disable individual backends for maintenance.  However, when I submit the form, no changes are saved.  Everything remains as it did originally.  I've not found any explaination for this in the debug logs.  The request goes through and appears to be processed, but no change is registered.

Based on some long ago reported problems, I've tried this with and without the :port appended in the BalancerMember declaration, but to no avail.

Additionally, I've noticed that if I visit https://mybalancedvhost.mydomain/balancer-manager I get a second "empty" section.

Some examples are attached.

Let me know if you need any more details.

Thanks,
Brian
Comment 1 bpkroth 2012-08-17 22:35:06 UTC
Created attachment 29250 [details]
example /balancer-manager output
Comment 2 Jim Jagielski 2012-11-01 14:45:39 UTC
The balancer-manager is designed to be per server and not server-wide. That is because it stores various parameters in shared memory which is associated with the particular server that the balancer is defined in.
Comment 3 bpkroth 2012-11-05 20:56:39 UTC
Adding this via the webform since I just realized my previous email replies didn't make it into the system ...

bugzilla@apache.org <bugzilla@apache.org> 2012-11-01 14:45:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=53736
>
> --- Comment #2 from Jim Jagielski <jim@apache.org> ---
> The balancer-manager is designed to be per server and not server-wide. That is
> because it stores various parameters in shared memory which is associated with
> the particular server that the balancer is defined in.

By "per server" do you mean "per vhost"?

As in, the confs should look like this instead?

<Proxy balancer://...>
	# Same balancer stuff as before ...
</Proxy>

<VirtualHost ...>
	# Same vhost stuff as before ...

	# Put this here, rather than at the top level.
	<Location /balancer-manager>
		SetHandler balancer-manager
		...
	</Location>
</VirtualHost>
# Rinse, repeat for each individual vhost ...

I think I had originally left it at the top because 
1) That's how the distro (Debian) packages that config file, and 
2) This page states the following:
http://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html#balancer_manager
Please note that only Balancers defined outside of <Location ...> containers can be dynamically controlled by the Manager.

However, that note doesn't show up in the 2.2 docs, which I'm currently running.

Thanks,
Brian
Comment 4 bpkroth 2012-11-05 20:57:20 UTC
Brian Paul Kroth <bpkroth@gmail.com> 2012-11-01 10:29:
> bugzilla@apache.org <bugzilla@apache.org> 2012-11-01 14:45:
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=53736
>>
>> --- Comment #2 from Jim Jagielski <jim@apache.org> ---
>> The balancer-manager is designed to be per server and not server-wide. That is
>> because it stores various parameters in shared memory which is associated with
>> the particular server that the balancer is defined in.
>
> By "per server" do you mean "per vhost"?
>
> As in, the confs should look like this instead?
>
> <Proxy balancer://...>
> 	# Same balancer stuff as before ...
> </Proxy>
>
> <VirtualHost ...>
> 	# Same vhost stuff as before ...
>
> 	# Put this here, rather than at the top level.
> 	<Location /balancer-manager>
> 		SetHandler balancer-manager
> 		...
> 	</Location>
> </VirtualHost>
> # Rinse, repeat for each individual vhost ...

I tried this, but I got the same results.  Any other ideas?

Thanks,
Brian
Comment 5 bpkroth 2013-02-09 00:01:54 UTC
So, I think I've figured out what the problem is here.  Basically, we have IPv6 backends that include [] characters (eg: http://[fded:ff:cb23:608:b774:712c]).  On the form submital, the w field is being ap_escape_uri()ed twice, so that [ becomes first %5b, and then %255b, but only ap_unescape_url()ed once.

I've attached a patch that just does the existing ap_unescape_url() call twice (just wrapped in a for loop).  There may be a better way to do that.


Here's the steps I used to track this down.

1) Throw in a bunch of ap_log_error() calls around the while (args ...) processing, wsel instantiation, and other params checking blocks to dump debug information out to the log and rebuild mod_proxy_balancer.so

2) Load the /balancer-manager page.

3) Click on one of the backends to pull up the form.  That results in output like the following:

[Thu Feb 07 17:55:33 2013] [debug] mod_proxy_balancer.c(719): proxy: balancer-manager handler got escaped w=http://%5bfded:ff::cb23:608:b774:712c%5d
[Thu Feb 07 17:55:33 2013] [debug] mod_proxy_balancer.c(729): proxy: balancer-manager handler got w=http://[fded:ff:cb23:608:b774:712c]
[Thu Feb 07 17:55:33 2013] [debug] mod_proxy_balancer.c(733): proxy: balancer-manager handler stored w=http://[fded:ff::cb23:608:b774:712c]
[Thu Feb 07 17:55:33 2013] [debug] mod_proxy_balancer.c(767): proxy: balancer-manager handler for balancer balancer://bpk-test_http_cluster requested worker http://[fded:ff::cb23:608:b774:712c], found ws http://[fded:ff::cb23:608:b774:712c], checking wsel http://[fded:ff::cb23:608:b774:712c]
[Thu Feb 07 17:55:33 2013] [debug] mod_proxy_balancer.c(787): proxy: balancer-manager handler for balancer balancer://bpk-test_http_cluster requested worker http://[fded:ff::cb23:608:b774:712c]

Notice that 
a) It's properly unescaping the w= GET parameter at that point.
b) From that it finds and sets wsel correctly.

4) View the source for that page.  You'll note that it generates the following html for an escaped w field:

<input type=hidden name="w" value="http://%5bfded:ff::cb23:608:b774:712c%5d">


5) Submit the form.  That results in output like the following:

[Thu Feb 07 17:55:39 2013] [debug] mod_proxy_balancer.c(719): proxy: balancer-manager handler got escaped w=http%3A%2F%2F%255bfded%3A%3Aff%3A%3Acb23%3A608%3Ab774%3A712c%255d
[Thu Feb 07 17:55:39 2013] [debug] mod_proxy_balancer.c(729): proxy: balancer-manager handler got w=http://%5bfded:ff::cb23:608:b774:712c%5d
[Thu Feb 07 17:55:39 2013] [debug] mod_proxy_balancer.c(733): proxy: balancer-manager handler stored w=http://%5bfded:ff::cb23:608:b774:712c%5d

Notice that
a) w is not entirely unescaped at this point, so that
b) wsel doesn't get set, so that 
c) the if (wsel) processing bit to change the worker's parameters never gets processed.

The attached patch fixes that.

Let me know if you have any questions.

Thanks,
Brian
Comment 6 bpkroth 2013-02-09 00:02:46 UTC
Created attachment 29933 [details]
mod_proxy_balancer-manager_ipv6_backends.patch
Comment 7 bpkroth 2013-02-09 00:03:49 UTC
Comment on attachment 29933 [details]
mod_proxy_balancer-manager_ipv6_backends.patch

unescape twice the doubly escaped ipv6 backend uri
Comment 8 William A. Rowe Jr. 2018-11-07 21:08:29 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.