summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/forwardauth
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2022-06-22 15:10:14 -0400
committerGitHub <noreply@github.com>2022-06-22 15:10:14 -0400
commit98468af8b6224d29431576fe30a7d92a8676030d (patch)
tree85a8eefb798af3d02b897545e305f76b97982557 /modules/caddyhttp/reverseproxy/forwardauth
parent25f10511e7ef80c10493519499c479f6ffa49a0f (diff)
reverseproxy: Fix double headers in response handlers (#4847)
Diffstat (limited to 'modules/caddyhttp/reverseproxy/forwardauth')
-rw-r--r--modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go47
1 files changed, 6 insertions, 41 deletions
diff --git a/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go b/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
index c22ddde..8230216 100644
--- a/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
@@ -59,13 +59,6 @@ func init() {
// Remote-Email {http.reverse_proxy.header.Remote-Email}
// }
// }
-//
-// handle_response {
-// copy_response_headers {
-// exclude Connection Keep-Alive Te Trailers Transfer-Encoding Upgrade
-// }
-// copy_response
-// }
// }
//
func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
@@ -217,41 +210,13 @@ func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error)
},
)
}
- rpHandler.HandleResponse = append(rpHandler.HandleResponse, goodResponseHandler)
- // set up handler for denial responses; when a response
- // has any other status than 2xx, then we copy the response
- // back to the client, and terminate handling.
- denialResponseHandler := caddyhttp.ResponseHandler{
- Routes: []caddyhttp.Route{
- {
- HandlersRaw: []json.RawMessage{caddyconfig.JSONModuleObject(
- &reverseproxy.CopyResponseHeadersHandler{
- Exclude: []string{
- "Connection",
- "Keep-Alive",
- "Te",
- "Trailers",
- "Transfer-Encoding",
- "Upgrade",
- },
- },
- "handler",
- "copy_response_headers",
- nil,
- )},
- },
- {
- HandlersRaw: []json.RawMessage{caddyconfig.JSONModuleObject(
- &reverseproxy.CopyResponseHandler{},
- "handler",
- "copy_response",
- nil,
- )},
- },
- },
- }
- rpHandler.HandleResponse = append(rpHandler.HandleResponse, denialResponseHandler)
+ // note that when a response has any other status than 2xx, then we
+ // use the reverse proxy's default behaviour of copying the response
+ // back to the client, so we don't need to explicitly add a response
+ // handler specifically for that behaviour; we do need the 2xx handler
+ // though, to make handling fall through to handlers deeper in the chain.
+ rpHandler.HandleResponse = append(rpHandler.HandleResponse, goodResponseHandler)
// the rest of the config is specified by the user
// using the reverse_proxy directive syntax