Welcome! Log In Create A New Profile

Advanced

Re: Issue with upstream

Maxim Dounin
November 16, 2010 09:56AM
Hello!

On Tue, Nov 16, 2010 at 01:16:25PM +0000, Phil Bayfield wrote:

> I'm having some problems configuring upstream servers with localhost backup
> (error page)
>
> upstream backend1 {
> server 1.2.3.4;
> server 2.3.4.5;
> server localhost backup;
> }
>
> upstream backend2 {
> server 3.4.5.6;
> server 4.5.6.7;
> }
>
> Works, but:
>
> upstream backend1 {
> server 1.2.3.4;
> server 2.3.4.5;
> server localhost backup;
> }
>
> upstream backend2 {
> server 3.4.5.6;
> server 4.5.6.7;
> server localhost backup;
> }
>
> Causes:
>
> Testing nginx configuration: [emerg]: invalid parameter "backup"
>
> Is this a bug?

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.

Attached patch makes sure such configuration like

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

upstream backend {
...
}

will generate "upstream "backend" defined too late" error during
configuration parsing.

Maxim Dounin
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
@@ -4220,6 +4220,12 @@ ngx_http_upstream_add(ngx_conf_t *cf, ng
return NULL;
}

+ if (flags & NGX_HTTP_UPSTREAM_CREATE) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "upstream \"%V\" defined too late", &u->host);
+ return NULL;
+ }
+
if ((uscfp[i]->flags & NGX_HTTP_UPSTREAM_CREATE) && u->port) {
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
"upstream \"%V\" may not have port %d",
@@ -4227,14 +4233,6 @@ ngx_http_upstream_add(ngx_conf_t *cf, ng
return NULL;
}

- if ((flags & NGX_HTTP_UPSTREAM_CREATE) && uscfp[i]->port) {
- ngx_log_error(NGX_LOG_WARN, cf->log, 0,
- "upstream \"%V\" may not have port %d in %s:%ui",
- &u->host, uscfp[i]->port,
- uscfp[i]->file_name, uscfp[i]->line);
- return NULL;
- }
-
if (uscfp[i]->port != u->port) {
continue;
}
_______________________________________________
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: 153
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