Welcome! Log In Create A New Profile

Advanced

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg
October 04, 2011 04:12AM
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@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!
Subject Author Posted

Does Nginx honor DNS TTLs for proxy upstreams?

csg September 26, 2011 04:42AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

Maxim Dounin September 26, 2011 05:38AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 26, 2011 09:40AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

Maxim Dounin September 26, 2011 09:58AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 28, 2011 12:05PM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

Maxim Dounin September 28, 2011 12:14PM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 28, 2011 03:35PM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 29, 2011 03:31AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 29, 2011 03:32AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 29, 2011 03:53AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

Maxim Dounin September 29, 2011 03:30AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg October 04, 2011 04:12AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 175
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready