Merge pull request #1769 from aledbf/port-redirect

Use custom https port in redirects
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-11-30 11:13:59 -03:00 committed by GitHub
commit 120bb1deb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -387,7 +387,13 @@ http {
{{ end }}
{{ end }}
server_name {{ $hostname }};
{{ if ne $all.ListenPorts.HTTPS 443 }}
{{ $redirect_port := (printf ":%v" $all.ListenPorts.HTTPS) }}
return 301 $scheme://{{ $to }}{{ $redirect_port }}$request_uri;
{{ else }}
return 301 $scheme://{{ $to }}$request_uri;
{{ end }}
}
{{ end }}
@ -679,7 +685,12 @@ stream {
{{ if (or $location.Rewrite.ForceSSLRedirect (and (not (empty $server.SSLCertificate)) $location.Rewrite.SSLRedirect)) }}
# enforce ssl on server side
if ($pass_access_scheme = http) {
{{ if ne $all.ListenPorts.HTTPS 443 }}
{{ $redirect_port := (printf ":%v" $all.ListenPorts.HTTPS) }}
return 301 https://$best_http_host{{ $redirect_port }}$request_uri;
{{ else }}
return 301 https://$best_http_host$request_uri;
{{ end }}
}
{{ end }}