Skip to content

Commit

Permalink
reverseproxy: Add flag of disable redirects
Browse files Browse the repository at this point in the history
* Fixes #5290
  • Loading branch information
u5surf committed Jan 24, 2023
1 parent 5805b3c commit 0b645fd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 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 redirect HTTP->HTTPS")
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 @@ -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},
Expand Down

0 comments on commit 0b645fd

Please sign in to comment.