From 86b785e51cccd5df18611c380962cbd4faf38af5 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 27 Feb 2020 10:20:13 -0700 Subject: reverse_proxy: Add 'transparent' Caddyfile subdirective (closes #2873) --- modules/caddyhttp/reverseproxy/caddyfile.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'modules') diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go index d08e7f1..a2b1898 100644 --- a/modules/caddyhttp/reverseproxy/caddyfile.go +++ b/modules/caddyhttp/reverseproxy/caddyfile.go @@ -411,6 +411,21 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { } h.TransportRaw = caddyconfig.JSONModuleObject(rt, "protocol", name, nil) + case "transparent": + if d.NextArg() { + return d.ArgErr() + } + if h.Headers == nil { + h.Headers = new(headers.Handler) + } + if h.Headers.Request == nil { + h.Headers.Request = new(headers.HeaderOps) + } + // The X-Forwarded-For header is always appended to by default, directly in the reverse proxy code + headers.CaddyfileHeaderOp(h.Headers.Request, "Host", "{http.request.hostport}", "") + headers.CaddyfileHeaderOp(h.Headers.Request, "X-Real-Ip", "{http.request.remote}", "") + headers.CaddyfileHeaderOp(h.Headers.Request, "X-Forwarded-Proto", "{http.request.scheme}", "") + default: return d.Errf("unrecognized subdirective %s", d.Val()) } -- cgit v1.2.3