aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2022-09-29 08:19:56 -0600
committerGitHub <[email protected]>2022-09-29 08:19:56 -0600
commite2991eb019e36b612be3d7b43ed961c7a7e3841d (patch)
tree99caa545ba49f7076cda423b3bdc8d91ddb30910
parent897a38958cb733551339f40f04e5798fcda55bcc (diff)
downloadcaddy-e2991eb019e36b612be3d7b43ed961c7a7e3841d.tar.gz
caddy-e2991eb019e36b612be3d7b43ed961c7a7e3841d.zip
reverseproxy: On 103 don't delete own headers (#5091)
See #5074
-rw-r--r--modules/caddyhttp/headers/caddyfile.go15
-rw-r--r--modules/caddyhttp/reverseproxy/reverseproxy.go5
2 files changed, 10 insertions, 10 deletions
diff --git a/modules/caddyhttp/headers/caddyfile.go b/modules/caddyhttp/headers/caddyfile.go
index eec11490c..a6bec9573 100644
--- a/modules/caddyhttp/headers/caddyfile.go
+++ b/modules/caddyhttp/headers/caddyfile.go
@@ -32,12 +32,12 @@ func init() {
// parseCaddyfile sets up the handler for response headers from
// Caddyfile tokens. Syntax:
//
-// header [<matcher>] [[+|-|?]<field> [<value|regexp>] [<replacement>]] {
-// [+]<field> [<value|regexp> [<replacement>]]
-// ?<field> <default_value>
-// -<field>
-// [defer]
-// }
+// header [<matcher>] [[+|-|?]<field> [<value|regexp>] [<replacement>]] {
+// [+]<field> [<value|regexp> [<replacement>]]
+// ?<field> <default_value>
+// -<field>
+// [defer]
+// }
//
// Either a block can be opened or a single header field can be configured
// in the first line, but not both in the same directive. Header operations
@@ -148,8 +148,7 @@ func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error)
// parseReqHdrCaddyfile sets up the handler for request headers
// from Caddyfile tokens. Syntax:
//
-// request_header [<matcher>] [[+|-]<field> [<value|regexp>] [<replacement>]]
-//
+// request_header [<matcher>] [[+|-]<field> [<value|regexp>] [<replacement>]]
func parseReqHdrCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
if !h.Next() {
return nil, h.ArgErr()
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go
index 4c8b29b13..55d3aa8ce 100644
--- a/modules/caddyhttp/reverseproxy/reverseproxy.go
+++ b/modules/caddyhttp/reverseproxy/reverseproxy.go
@@ -782,8 +782,9 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe
copyHeader(h, http.Header(header))
rw.WriteHeader(code)
- // Clear headers, it's not automatically done by ResponseWriter.WriteHeader() for 1xx responses
- for k := range h {
+ // Clear headers coming from the backend
+ // (it's not automatically done by ResponseWriter.WriteHeader() for 1xx responses)
+ for k := range header {
delete(h, k)
}