Change condition order that produces endless loop

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-04-02 20:41:31 -03:00
parent 5390ce4879
commit 8527f774f7

View file

@ -61,12 +61,12 @@ local function redirect_to_https(location_config)
return false return false
end end
if ngx.var.pass_access_scheme ~= "http" then if location_config.force_ssl_redirect and ngx.var.pass_access_scheme == "http" then
return false return true
end end
if location_config.force_ssl_redirect then if ngx.var.pass_access_scheme ~= "http" then
return true return false
end end
return location_config.ssl_redirect and certificate_configured_for_current_request() return location_config.ssl_redirect and certificate_configured_for_current_request()
@ -105,6 +105,7 @@ end
-- phases or redirection -- phases or redirection
function _M.rewrite(location_config) function _M.rewrite(location_config)
ngx.var.pass_access_scheme = ngx.var.scheme ngx.var.pass_access_scheme = ngx.var.scheme
ngx.var.best_http_host = ngx.var.http_host or ngx.var.host ngx.var.best_http_host = ngx.var.http_host or ngx.var.host
if config.use_forwarded_headers then if config.use_forwarded_headers then