Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 06:45 UTC
reverseproxy: Add flag to short command to disable redirects (#5330)
Co-authored-by: Francis Lavoie <lavofr@gmail.com> Fixes undefined
Y.Horie committed
Jan 25, 2023 at 23:40 UTC
e9d95ab29f6cbf24fd3f7f7fd439ab31e2797f93
1 file changed
+4
modules/caddyhttp/reverseproxy/command.go
+4
@@ -64,6 +64,7 @@ default, all incoming headers are passed through unmodified.)
64
fs.Bool("insecure", false, "Disable TLS verification (WARNING: DISABLES SECURITY BY NOT VERIFYING SSL CERTIFICATES!)")
65
fs.Bool("internal-certs", false, "Use internal CA for issuing certs")
66
fs.Bool("debug", false, "Enable verbose debug logs")
67
+ fs.Bool("disable-redirects", false, "Disable HTTP->HTTPS redirects")
68
return fs
69
}(),
70
})
@@ -77,6 +78,7 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) {
78
insecure := fs.Bool("insecure")
79
internalCerts := fs.Bool("internal-certs")
80
debug := fs.Bool("debug")
81
+ disableRedir := fs.Bool("disable-redirects")
82
83
httpPort := strconv.Itoa(caddyhttp.DefaultHTTPPort)
84
httpsPort := strconv.Itoa(caddyhttp.DefaultHTTPSPort)
@@ -174,6 +176,8 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) {
176
177
if fromAddr.Scheme == "http" {
178
server.AutoHTTPS = &caddyhttp.AutoHTTPSConfig{Disabled: true}
179
+ } else if disableRedir {
180
+ server.AutoHTTPS = &caddyhttp.AutoHTTPSConfig{DisableRedir: true}
181
}
182
183
httpApp := caddyhttp.App{