limit proxy_next_upstream

Maxim Dounin mdounin at mdounin.ru
Fri Apr 5 10:12:37 UTC 2013


Hello!

On Fri, Apr 05, 2013 at 04:38:36AM -0400, philipp wrote:

> Is it possible to limit the amount of upstreams asked? I have four upstreams
> defined and it makes no sense to ask all of them. If two of them timeout or
> error there is possible something wrong with the request and asking another
> node doesn't help.

No, as of now only switching off proxy_next_upstream completely is 
available.

On the other hand, with switched of proxy_next_upstream you may 
still configure retries to additional (or other) upstream servers 
via error_page directive, using a configuration similar to last 
example at http://nginx.org/r/error_page.

Something like this should generate no more than two requests 
regardless of number of upstream servers configured:

    location / {
        error_page 502 504 = @fallback;
        proxy_pass http://backend;
        proxy_next_upstream off;
    }

    location @fallback {
        proxy_pass http://backend;
        proxy_next_upstream off;
    }

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx mailing list