1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2024-11-24 08:52:25 +02:00

Confirm that the proto is not empty, and change condition to OR

Co-Authored-By: Joel Speed <Joel.speed@hotmail.co.uk>
This commit is contained in:
Josh Michielsen 2019-10-22 14:21:06 +01:00 committed by GitHub
parent fe9efba0c5
commit c0bfe0357a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}