aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/reverseproxy
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2024-07-18 21:31:07 -0600
committerMatthew Holt <[email protected]>2024-07-18 21:31:07 -0600
commit806f5b111781a3b2734223c8e14780d86ac4edd5 (patch)
tree502b38cbe6093112c7aefa24b0513aaf972c3f50 /modules/caddyhttp/reverseproxy
parentb2492f8567069c223eab2156d18904c03f9dc4f3 (diff)
downloadcaddy-806f5b111781a3b2734223c8e14780d86ac4edd5.tar.gz
caddy-806f5b111781a3b2734223c8e14780d86ac4edd5.zip
reverseproxy: Fix panic when using header-related flags (fix #6464)
Diffstat (limited to 'modules/caddyhttp/reverseproxy')
-rw-r--r--modules/caddyhttp/reverseproxy/command.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/caddyhttp/reverseproxy/command.go b/modules/caddyhttp/reverseproxy/command.go
index 59fa67df0..f9304efa2 100644
--- a/modules/caddyhttp/reverseproxy/command.go
+++ b/modules/caddyhttp/reverseproxy/command.go
@@ -229,11 +229,13 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) {
if changeHost {
if handler.Headers == nil {
- handler.Headers = &headers.Handler{
- Request: &headers.HeaderOps{
- Set: http.Header{},
- },
- }
+ handler.Headers = new(headers.Handler)
+ }
+ if handler.Headers.Request == nil {
+ handler.Headers.Request = new(headers.HeaderOps)
+ }
+ if handler.Headers.Request.Set == nil {
+ handler.Headers.Request.Set = http.Header{}
}
handler.Headers.Request.Set.Set("Host", "{http.reverse_proxy.upstream.hostport}")
}