Fix custom port in redirects (#1907)
This commit is contained in:
parent
74451e6b1f
commit
b0e0712984
1 changed files with 5 additions and 2 deletions
|
@ -693,10 +693,13 @@ stream {
|
||||||
{{/* redirect to HTTPS can be achieved forcing the redirect or having a SSL Certificate configured for the server */}}
|
{{/* redirect to HTTPS can be achieved forcing the redirect or having a SSL Certificate configured for the server */}}
|
||||||
{{ if (or $location.Rewrite.ForceSSLRedirect (and (not (empty $server.SSLCertificate)) $location.Rewrite.SSLRedirect)) }}
|
{{ if (or $location.Rewrite.ForceSSLRedirect (and (not (empty $server.SSLCertificate)) $location.Rewrite.SSLRedirect)) }}
|
||||||
# enforce ssl on server side
|
# enforce ssl on server side
|
||||||
if ($redirect_to_https) {
|
if ($redirect_to_https) {
|
||||||
{{ if $location.UsePortInRedirects }}
|
{{ if $location.UsePortInRedirects }}
|
||||||
|
# using custom ports require a different rewrite directive
|
||||||
{{ $redirect_port := (printf ":%v" $all.ListenPorts.HTTPS) }}
|
{{ $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 }}
|
{{ else }}
|
||||||
return {{ $all.Cfg.HTTPRedirectCode }} https://$best_http_host$request_uri;
|
return {{ $all.Cfg.HTTPRedirectCode }} https://$best_http_host$request_uri;
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue