diff --git a/modules/caddyhttp/reverseproxy/command.go b/modules/caddyhttp/reverseproxy/command.go index ca62191040a0..59ad9d130618 100644 --- a/modules/caddyhttp/reverseproxy/command.go +++ b/modules/caddyhttp/reverseproxy/command.go @@ -64,6 +64,7 @@ default, all incoming headers are passed through unmodified.) fs.Bool("insecure", false, "Disable TLS verification (WARNING: DISABLES SECURITY BY NOT VERIFYING SSL CERTIFICATES!)") fs.Bool("internal-certs", false, "Use internal CA for issuing certs") fs.Bool("debug", false, "Enable verbose debug logs") + fs.Bool("disable-redirects", false, "Disable redirect HTTP->HTTPS") return fs }(), }) @@ -77,6 +78,7 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) { insecure := fs.Bool("insecure") internalCerts := fs.Bool("internal-certs") debug := fs.Bool("debug") + disableRedir := fs.Bool("disable-redirects") httpPort := strconv.Itoa(caddyhttp.DefaultHTTPPort) httpsPort := strconv.Itoa(caddyhttp.DefaultHTTPSPort) @@ -175,6 +177,13 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) { if fromAddr.Scheme == "http" { server.AutoHTTPS = &caddyhttp.AutoHTTPSConfig{Disabled: true} } + if disableRedir { + if server.AutoHTTPS != nil { + server.AutoHTTPS = &caddyhttp.AutoHTTPSConfig{DisabledRidir: true} + } else { + server.AutoHTTPS.DisableRedir = true + } + } httpApp := caddyhttp.App{ Servers: map[string]*caddyhttp.Server{"proxy": server},