Merge pull request #1769 from aledbf/port-redirect
Use custom https port in redirects
This commit is contained in:
commit
120bb1deb0
1 changed files with 11 additions and 0 deletions
|
@ -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 }}
|
||||
|
||||
|
|
Loading…
Reference in a new issue