reverseproxy: Err 503 if all upstreams unavailable

This commit is contained in:
Matthew Holt 2022-07-08 13:01:02 -06:00
parent 54d1923ccb
commit d6bc9e0b5c
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
1 changed files with 1 additions and 1 deletions

View File

@ -477,7 +477,7 @@ func (h *Handler) proxyLoopIteration(r *http.Request, origReq *http.Request, w h
upstream := h.LoadBalancing.SelectionPolicy.Select(upstreams, r, w)
if upstream == nil {
if proxyErr == nil {
proxyErr = fmt.Errorf("no upstreams available")
proxyErr = caddyhttp.Error(http.StatusServiceUnavailable, fmt.Errorf("no upstreams available"))
}
if !h.LoadBalancing.tryAgain(h.ctx, start, proxyErr, r) {
return true, proxyErr