Skip to content

Commit

Permalink
reverseproxy: Add flag to short command to disable redirects (#5330)
Browse files Browse the repository at this point in the history
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Fixes undefined
  • Loading branch information
u5surf committed Jan 25, 2023
1 parent 9623102 commit e9d95ab
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/caddyhttp/reverseproxy/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 HTTP->HTTPS redirects")
return fs
}(),
})
Expand All @@ -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)
Expand Down Expand Up @@ -174,6 +176,8 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) {

if fromAddr.Scheme == "http" {
server.AutoHTTPS = &caddyhttp.AutoHTTPSConfig{Disabled: true}
} else if disableRedir {
server.AutoHTTPS = &caddyhttp.AutoHTTPSConfig{DisableRedir: true}
}

httpApp := caddyhttp.App{
Expand Down

0 comments on commit e9d95ab

Please sign in to comment.