Does Nginx honor DNS TTLs for proxy upstreams?
csg
nginx-forum at nginx.us
Tue Oct 4 08:12:59 UTC 2011
Hi Maxim and Igor!
in the meantime we served around 15 million requests successfully
without any issue on production. As a long term fix would it be possible
for get Maxims' patch merged into to the official code base. As this is
a change in behavior I would understand if it doesn't get merged into
the stable branch, but merging this into the development branch would be
excellent.
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1317281138 -14400
# Node ID d6a0787307868c06073d92bb39eb2f73acf19d7c
# Parent 29d417d419d946dce33023c71cce0e586ef3547b
Proxy: made proxy_pass with variables more consitent.
If proxy_pass were used with variables and there were no URI component,
nginx always used unparsed URI. This isn't consistent with "no
variables"
case, where e.g. rewrites are applied even if there are no URI
component.
Fix is to use same logic in both cases, i.e. only use unparsed URI if
it's valid and request is main one.
diff --git a/src/http/modules/ngx_http_proxy_module.c
b/src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -738,9 +738,6 @@ ngx_http_proxy_eval(ngx_http_request_t *
url.uri.len++;
url.uri.data = p - 1;
}
-
- } else {
- url.uri = r->unparsed_uri;
}
ctx->vars.key_start = u->schema;
@@ -808,7 +805,7 @@ ngx_http_proxy_create_key(ngx_http_reque
return NGX_ERROR;
}
- if (plcf->proxy_lengths) {
+ if (plcf->proxy_lengths && ctx->vars.uri.len) {
*key = ctx->vars.uri;
u->uri = ctx->vars.uri;
@@ -918,7 +915,7 @@ ngx_http_proxy_create_request(ngx_http_r
loc_len = 0;
unparsed_uri = 0;
- if (plcf->proxy_lengths) {
+ if (plcf->proxy_lengths && ctx->vars.uri.len) {
uri_len = ctx->vars.uri.len;
} else if (ctx->vars.uri.len == 0 && r->valid_unparsed_uri && r ==
r->main)
@@ -1024,7 +1021,7 @@ ngx_http_proxy_create_request(ngx_http_r
u->uri.data = b->last;
- if (plcf->proxy_lengths) {
+ if (plcf->proxy_lengths && ctx->vars.uri.len) {
b->last = ngx_copy(b->last, ctx->vars.uri.data,
ctx->vars.uri.len);
} else if (unparsed_uri) {
Many thanks!
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,215830,216240#msg-216240
More information about the nginx
mailing list