Welcome! Log In Create A New Profile

Advanced

Re: Use next Balanced member if 503 error

Maxim Dounin
December 07, 2012 02:08PM
Hello!

On Thu, Dec 06, 2012 at 12:34:18PM -0500, marcosluna79 wrote:

> Hello I am working with nginx as balancer between two jetty servers.
>
> The balancing is working but I am facing a problem when a 503 error is
> generated by one of the servers, I added the line
>
> proxy_next_upstream error timeout invalid_header http_500 http_503;
>
> It seems not to work when one of the servers fail because a resource is lost
> like a DB connection. I can see the 503 error page instead of the correct
> page in the other balanced member.
>
> I have checked that the other server do have a valid DB connection but nginx
> fails to forward to it.

The 503 error may be returned even with "proxy_next_upstream
http_503" configured e.g. if both backends return 503 or one of the
backends was already considered down for some reason (due to
previous errors).

If you want to investigate what goes on in your case, you probably
want to log details on upstream communication like $upstream_addr,
$upstream_status, see here for more details:

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#variables

Just in case, trivial config to test that "proxy_next_upstream
http_503" actually works:

http {
upstream backends {
server 127.0.0.1:8081;
server 127.0.0.1:8082;
}

server {
listen 8080;

location / {
proxy_pass http://backends;
proxy_next_upstream error timeout http_503;
}
}

server {
listen 8081;
return 503;
}

server {
listen 8082;
return 200 "OK\n";
}
}

And trivial test with curl:

$ curl http://127.0.0.1:8080/
OK
$ curl http://127.0.0.1:8080/
OK
$ curl http://127.0.0.1:8080/
OK
$ curl http://127.0.0.1:8080/
OK

--
Maxim Dounin
http://nginx.com/support.html

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

Use next Balanced member if 503 error

marcosluna79 December 06, 2012 12:34PM

Re: Use next Balanced member if 503 error

Maxim Dounin December 07, 2012 02:08PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 173
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