[PATCH] Core: fix content handler and location configuration mismatch.
Maxim Dounin
mdounin at mdounin.ru
Fri Dec 7 16:27:45 UTC 2012
Hello!
On Thu, Dec 06, 2012 at 05:14:11PM -0800, Piotr Sikora wrote:
> Core: fix content handler and location configuration mismatch.
>
> When using exclusive content handlers (proxy_pass, etc.) and "if"
> pseudo-locations, content handler was always set to the one from the
> last "if" pseudo-location that evaluated to true or to the one from
> the location block if "if" pseudo-locations didn't provide any.
> At the same time, location configuration was updated for each "if"
> pseudo-location that evaluated to true, which resulted in content
> handler and location configuration mismatch.
>
> For example, following configuration would result in SIGSEGV, because
> "proxy_pass" content handler (set in the "if ($pass)" pseudo-location)
> would be called with location configuration from the "if ($slow)"
> pseudo-location which doesn't contain any upstream configuration.
>
> location / {
> set $pass 1;
> set $slow 1;
>
> if ($pass) {
> proxy_pass http://127.0.0.1:8000;
> }
>
> if ($slow) {
> limit_rate 10k;
> }
> }
>
> This patch fixes this issue by keeping track of and restoring location
> configuration from which the content handler originated.
And what will happen with the configuration specified in the "if
($slow) { ... }" as in the config above?
For limit_rate your config will work as it's saved in request by
ngx_http_update_location_config(), but e.g.
if ($slow) {
add_header "X-Accel-Limit-Rate: 10k";
}
will silently ignore if() match, which is wrong.
[...]
--
Maxim Dounin
http://nginx.com/support.html
More information about the nginx-devel
mailing list