Why Nginx send traffic to the next upstream on 504 error

Maxim Dounin mdounin at mdounin.ru
Mon Aug 10 12:46:49 UTC 2020


On Sun, Aug 09, 2020 at 10:45:14AM -0400, stmx38 wrote:

> Maxim, thank you for reply!
> Some additional question here:
> 1. If we will remove 'timeout' will Nginx send traffic to the next upstream
> on 502 error?

The "timeout" parameter corresponds to 504 returned to clients and 
in $upstream_status, the "error" one corresponds to 502 returned to 
clients and in $upstream_status.  Accordingly, removing "timeout" 
won't affect anything related to 502.  It will, however, stop nginx 
from trying next upstream servers on timeouts, also known as 504.

> 2. More general question related the the Q.1. When Nginx interpret reply as
> 502 - on timeout, if yes - on which one? We have a lot of timeouts defined
> in the main config:
> ----
>   client_header_timeout 30s;
>   client_body_timeout   30s;
>   send_timeout          65s;
>   proxy_connect_timeout 5s;
>   proxy_send_timeout    65s;
>   proxy_read_timeout    65s;
> ----

Quoting the docs (http://nginx.org/r/proxy_next_upstream):

    a timeout has occurred while establishing a connection with the 
    server, passing a request to it, or reading the response header;

That is, this implies timeouts when working with upstream server.  
Relevant configuration directives are proxy_connect_timeout, 
proxy_send_timeout, and proxy_read_timeout.

Maxim Dounin

More information about the nginx mailing list