Why Nginx send traffic to the next upstream on 504 error

Maxim Dounin mdounin at mdounin.ru
Sun Aug 9 12:29:43 UTC 2020


Hello!

On Sat, Aug 08, 2020 at 12:55:47PM -0400, stmx38 wrote:

> We have an Nginx where we configured
> http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream
> in Nginx main config file at http level.
> 
> We don't want to send traffic to the next upstream on 504:
> ----
> proxy_next_upstream    error timeout http_502 http_503 non_idempotent;
> ----
> 
> At vhost level we don't redefine this directive. But periodically we see the
> following in Nginx logs:
> ----
> 141.101.69.85 - 192.168.1.10 - 59.489 - [08/Aug/2020:11:10:41.098 +0000] -
> POST - /api/ - HTTP/1.1 - 499 -  - 0 - 2054 - "Java/1.8.0_242" - api-worker
> - "192.168.1.11:8080, 192.168.1.12:8080" - "504, -" - "0.000, 0.000" -
> "31.000, 28.489"
> ----
> 
> api-worker - "192.168.1.11:8080, 192.168.1.12:8080" - "504, -"
> 
> From the logs we see that Nginx received 504 status from the first upstream
> and then for some reason send traffic to the next one, despite the fact that
> it should not do it on 504 http status.

The "504" status in $uptream_status is used to indicate timeouts, 
much like 502 to indicate errors.  These are status codes nginx 
itself generates due to observed error conditions.  And your 
"proxy_next_upstream" includes "timeout".

[...]

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list