Fix custom port in redirects (#1907)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-01-17 10:20:41 -02:00 committed by GitHub
parent 74451e6b1f
commit b0e0712984
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -695,8 +695,11 @@ stream {
# enforce ssl on server side
if ($redirect_to_https) {
{{ if $location.UsePortInRedirects }}
# using custom ports require a different rewrite directive
{{ $redirect_port := (printf ":%v" $all.ListenPorts.HTTPS) }}
return {{ $all.Cfg.HTTPRedirectCode }} https://$best_http_host{{ $redirect_port }}$request_uri;
error_page 497 ={{ $all.Cfg.HTTPRedirectCode }} https://$best_http_host{{ $redirect_port }}$request_uri;
return 497;
{{ else }}
return {{ $all.Cfg.HTTPRedirectCode }} https://$best_http_host$request_uri;
{{ end }}