From 43b56d621b93f5450b037f2275179135d2d5587b Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 27 Jun 2017 12:10:03 -0600 Subject: [PATCH] Allow duplicate Server headers when proxying response See discussion on commit c9b022b5e0384ab97812366aade0bb34304459af If we overwrite the Server header, it becomes difficult/impossible to know from the client whether the request was proxied through Caddy. --- caddyhttp/proxy/reverseproxy.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/caddyhttp/proxy/reverseproxy.go b/caddyhttp/proxy/reverseproxy.go index 5fc4aed9..08bfdd56 100644 --- a/caddyhttp/proxy/reverseproxy.go +++ b/caddyhttp/proxy/reverseproxy.go @@ -413,8 +413,12 @@ func copyHeader(dst, src http.Header) { if _, shouldSkip := skipHeaders[k]; shouldSkip { continue } - // otherwise, overwrite - dst.Del(k) + // otherwise, overwrite to avoid duplicated fields that can be + // problematic (see issue #1086) -- however, allow duplicate + // Server fields so we can see the reality of the proxying. + if k != "Server" { + dst.Del(k) + } } for _, v := range vv { dst.Add(k, v)