Skip to content

Commit

Permalink
Updating from/to www redirect to use X-Forwarded-Proto (#7623)
Browse files Browse the repository at this point in the history
  • Loading branch information
aloisbarreras authored Jan 16, 2022
1 parent ae6ab1d commit 0bc01f7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,17 @@ http {
request_uri = string.sub(request_uri, 1, -2)
end

{{ if $cfg.UseForwardedHeaders }}
local redirectScheme = ngx.var.http_x_forwarded_proto
{{ else }}
local redirectScheme = ngx.var.scheme
{{ end }}

{{ if ne $all.ListenPorts.HTTPS 443 }}
{{ $redirect_port := (printf ":%v" $all.ListenPorts.HTTPS) }}
return string.format("%s://%s%s%s", ngx.var.scheme, "{{ $redirect.To }}", "{{ $redirect_port }}", request_uri)
return string.format("%s://%s%s%s", redirectScheme, "{{ $redirect.To }}", "{{ $redirect_port }}", request_uri)
{{ else }}
return string.format("%s://%s%s", ngx.var.scheme, "{{ $redirect.To }}", request_uri)
return string.format("%s://%s%s", redirectScheme, "{{ $redirect.To }}", request_uri)
{{ end }}
}

Expand Down

0 comments on commit 0bc01f7

Please sign in to comment.