[PATCH 0 of 2] improved upstream error response handling

Maxim Dounin mdounin at mdounin.ru
Sun Jan 11 22:58:58 UTC 2026


Hello!

The following patch series introduces a couple of improvements to
handling of HTTP error responses got from upstream servers:

1. If an error is listed in proxy_next_upstream (and friends), such as
   with "proxy_next_upstream http_502", balancer is now informed about
   the failure even if we weren't able to switch to the next upstream
   server due to additional restriction (such as number of tries or
   non-idempotent request).  Notably, this fixes gRPC proxying
   with "grpc_next_upstream http_502", which previously never switched
   of a server which only returned 502 errors.

2. If an error is listed in proxy_next_upstream (and friends) and
   considered to be a failure, and there is a stale cached response
   with "Cache-Control: stale-if-error=...", such a response will be
   sent to the client, much like it happens with network errors.

See relevant patches for more details.

Review and testing appreciated.

-- 
Maxim Dounin



More information about the nginx-devel mailing list