@@ -156,7 +156,7 @@ func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) {
156156func redirectToHTTPS(opts *Options, h http.Handler) http.Handler {
157157 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
158158 proto := r.Header.Get("X-Forwarded-Proto")
159− if opts.ForceHTTPS && r.TLS == nil && strings.ToLower(proto) != "https" {
159+ if opts.ForceHTTPS && (r.TLS == nil || (proto != "" && strings.ToLower(proto) != "https")) {
160160 http.Redirect(w, r, opts.HTTPSAddress, http.StatusPermanentRedirect)
161161 }
162162