summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go46
1 files changed, 24 insertions, 22 deletions
diff --git a/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go b/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
index 8230216..a0b1f42 100644
--- a/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
@@ -185,32 +185,34 @@ func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error)
},
Routes: []caddyhttp.Route{},
}
- if len(headersToCopy) > 0 {
- handler := &headers.Handler{
- Request: &headers.HeaderOps{
- Set: http.Header{},
- },
- }
- for from, to := range headersToCopy {
- handler.Request.Set[to] = []string{
- "{http.reverse_proxy.header." + from + "}",
- }
- }
+ handler := &headers.Handler{
+ Request: &headers.HeaderOps{
+ Set: http.Header{},
+ },
+ }
- goodResponseHandler.Routes = append(
- goodResponseHandler.Routes,
- caddyhttp.Route{
- HandlersRaw: []json.RawMessage{caddyconfig.JSONModuleObject(
- handler,
- "handler",
- "headers",
- nil,
- )},
- },
- )
+ // the list of headers to copy may be empty, but that's okay; we
+ // need at least one handler in the routes for the response handling
+ // logic in reverse_proxy to not skip this entry as empty.
+ for from, to := range headersToCopy {
+ handler.Request.Set[to] = []string{
+ "{http.reverse_proxy.header." + from + "}",
+ }
}
+ goodResponseHandler.Routes = append(
+ goodResponseHandler.Routes,
+ caddyhttp.Route{
+ HandlersRaw: []json.RawMessage{caddyconfig.JSONModuleObject(
+ handler,
+ "handler",
+ "headers",
+ nil,
+ )},
+ },
+ )
+
// 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