diff --git a/http.go b/http.go index b7ee9598..88280c44 100644 --- a/http.go +++ b/http.go @@ -156,7 +156,7 @@ func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) { func redirectToHTTPS(opts *Options, h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { proto := r.Header.Get("X-Forwarded-Proto") - if opts.ForceHTTPS && r.TLS == nil && strings.ToLower(proto) != "https" { + if opts.ForceHTTPS && (r.TLS == nil || (proto != "" && strings.ToLower(proto) != "https")) { http.Redirect(w, r, opts.HTTPSAddress, http.StatusPermanentRedirect) }