Mercurial > hg > nginx
comparison src/http/modules/ngx_http_proxy_module.c @ 5938:cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
The proxy_pass directive and other handlers are not expected to be inherited
into nested locations, but there is a special code to inherit upstream
handlers into limit_except blocks, as well as a configuration into if{}
blocks. This caused incorrect behaviour in configurations with nested
locations and limit_except blocks, like this:
location / {
proxy_pass http://u;
location /inner/ {
# no proxy_pass here
limit_except GET {
# nothing
}
}
}
In such a configuration the limit_except block inside "location /inner/"
unexpectedly used proxy_pass defined in "location /", while it shouldn't.
Fix is to avoid inheritance of conf->upstream.upstream (and
conf->proxy_lengths) into locations which don't have noname flag.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 09 Dec 2014 18:22:31 +0300 |
parents | 5b9f711dc819 |
children | aeea0522332f |
comparison
equal
deleted
inserted
replaced
5937:5b9f711dc819 | 5938:cd2abf7e7740 |
---|---|
2989 != NGX_OK) | 2989 != NGX_OK) |
2990 { | 2990 { |
2991 return NGX_CONF_ERROR; | 2991 return NGX_CONF_ERROR; |
2992 } | 2992 } |
2993 | 2993 |
2994 if (conf->upstream.upstream == NULL && conf->proxy_lengths == NULL) { | 2994 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
2995 | |
2996 if (clcf->noname | |
2997 && conf->upstream.upstream == NULL && conf->proxy_lengths == NULL) | |
2998 { | |
2995 conf->upstream.upstream = prev->upstream.upstream; | 2999 conf->upstream.upstream = prev->upstream.upstream; |
2996 conf->vars = prev->vars; | 3000 conf->vars = prev->vars; |
2997 | 3001 |
2998 conf->proxy_lengths = prev->proxy_lengths; | 3002 conf->proxy_lengths = prev->proxy_lengths; |
2999 conf->proxy_values = prev->proxy_values; | 3003 conf->proxy_values = prev->proxy_values; |
3001 #if (NGX_HTTP_SSL) | 3005 #if (NGX_HTTP_SSL) |
3002 conf->upstream.ssl = prev->upstream.ssl; | 3006 conf->upstream.ssl = prev->upstream.ssl; |
3003 #endif | 3007 #endif |
3004 } | 3008 } |
3005 | 3009 |
3006 if (conf->upstream.upstream || conf->proxy_lengths) { | 3010 if (clcf->lmt_excpt && clcf->handler == NULL |
3007 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); | 3011 && (conf->upstream.upstream || conf->proxy_lengths)) |
3008 if (clcf->handler == NULL && clcf->lmt_excpt) { | 3012 { |
3009 clcf->handler = ngx_http_proxy_handler; | 3013 clcf->handler = ngx_http_proxy_handler; |
3010 conf->location = prev->location; | 3014 conf->location = prev->location; |
3011 } | |
3012 } | 3015 } |
3013 | 3016 |
3014 if (conf->body_source.data == NULL) { | 3017 if (conf->body_source.data == NULL) { |
3015 conf->body_flushes = prev->body_flushes; | 3018 conf->body_flushes = prev->body_flushes; |
3016 conf->body_source = prev->body_source; | 3019 conf->body_source = prev->body_source; |