Welcome! Log In Create A New Profile

Advanced

Re: Issue with upstream

Maxim Dounin
January 06, 2011 03:04AM
Hello!

On Tue, Nov 16, 2010 at 05:49:16PM +0300, Maxim Dounin wrote:

[...]

> Most likely you used backend2 somewhere in proxy_pass before
> defining upstream backend2. This is not generally supported and
> and shouldn't be allowed, but happens to "work" (though with
> several unexpected side effects) for now.

Disregard this (and patch). Actually, the only thing which won't
work as expected is an attempt to redefine unix socket with
upstream{} block.

New patch attached.

Maxim Dounin
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1294300660 -10800
# Node ID b44ea37346fc2107a14a78a61cdb7d1866fdfa77
# Parent aab3af62ad3bbaee7bab6c6425074cfb5bc6973a
Better handle late upstream creation.

Configuration with duplicate upstream blocks defined after first use, i.e.
like

server {
...
location / {
proxy_pass http://backend;
}
}

upstream backend { ... }
upstream backend { ... }

now correctly results in "duplicate upstream" error.

Additionally, upstream blocks defined after first use now handle various
server directive parameters ("weight", "max_fails", etc.). Previously
configuration like

server {
...
location / {
proxy_pass http://backend;
}
}

upstream backend {
server 127.0.0.1 max_fails=5;
}

incorrectly resulted in "invalid parameter "max_fails=5"" error.

Note that an attempt to redefine unix socket would produce unexpected
results. Config like

server {
...
location / {
proxy_pass http://unix:/path/to/socket;
}
}

upstream "/path/to/socket" {
server 127.0.0.1;
}

would use upstream with two servers: one with unix socket "/path/to/socket",
and one 127.0.0.1.

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -4245,6 +4245,10 @@ ngx_http_upstream_add(ngx_conf_t *cf, ng
continue;
}

+ if (flags & NGX_HTTP_UPSTREAM_CREATE) {
+ uscfp[i]->flags = flags;
+ }
+
return uscfp[i];
}

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Issue with upstream

Phil Bayfield November 16, 2010 08:20AM

Re: Issue with upstream

Phil Bayfield November 16, 2010 09:30AM

Re: Issue with upstream

Maxim Dounin November 16, 2010 09:56AM

Re: Issue with upstream

Phil Bayfield November 16, 2010 10:04AM

Re: Issue with upstream

Maxim Dounin November 16, 2010 01:30PM

Re: Issue with upstream

António P. P. Almeida November 16, 2010 01:40PM

Re: Issue with upstream

Maxim Dounin November 16, 2010 02:10PM

Re: Issue with upstream

Phil Bayfield November 16, 2010 03:18PM

Re: Issue with upstream

Maxim Dounin November 16, 2010 03:40PM

Re: Issue with upstream

Phil Bayfield November 17, 2010 07:40AM

Re: Issue with upstream

Maxim Dounin January 06, 2011 03:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 162
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready