From 9f16ac84a0e80fcfe3ade8f3a9b2b06ffccaea50 Mon Sep 17 00:00:00 2001 From: ericdreeves Date: Sat, 3 Dec 2016 16:31:29 -0600 Subject: [PATCH] Return HTTP 504 when FastCGI connect times out. --- caddyhttp/fastcgi/fastcgi.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/caddyhttp/fastcgi/fastcgi.go b/caddyhttp/fastcgi/fastcgi.go index ac29eb739..c4dd9b32c 100644 --- a/caddyhttp/fastcgi/fastcgi.go +++ b/caddyhttp/fastcgi/fastcgi.go @@ -81,6 +81,9 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) // Connect to FastCGI gateway fcgiBackend, err := rule.dialer.Dial() if err != nil { + if err, ok := err.(net.Error); ok && err.Timeout() { + return http.StatusGatewayTimeout, err + } return http.StatusBadGateway, err } defer fcgiBackend.Close()