mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +00:00
chore: Consistent indentation
This commit is contained in:
parent
f20662eeaa
commit
0da38122bd
83
nginx.tmpl
83
nginx.tmpl
@ -83,7 +83,7 @@
|
||||
{{- else if (exists "/etc/nginx/vhost.d/default_location") }}
|
||||
include /etc/nginx/vhost.d/default_location;
|
||||
{{- end }}
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
{{- define "upstream" }}
|
||||
@ -234,9 +234,9 @@ server {
|
||||
server_name _; # This is just an invalid value which will never trigger on a real hostname.
|
||||
server_tokens off;
|
||||
listen {{ $external_http_port }};
|
||||
{{- if $enable_ipv6 }}
|
||||
{{- if $enable_ipv6 }}
|
||||
listen [::]:{{ $external_http_port }};
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ $access_log }}
|
||||
return 503;
|
||||
|
||||
@ -255,63 +255,62 @@ server {
|
||||
|
||||
{{- range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
||||
|
||||
{{- $host := trim $host }}
|
||||
{{- $is_regexp := hasPrefix "~" $host }}
|
||||
{{- $upstream_name := when (or $is_regexp $sha1_upstream_name) (sha1 $host) $host }}
|
||||
{{- $host := trim $host }}
|
||||
{{- $is_regexp := hasPrefix "~" $host }}
|
||||
{{- $upstream_name := when (or $is_regexp $sha1_upstream_name) (sha1 $host) $host }}
|
||||
|
||||
{{- $paths := groupBy $containers "Env.VIRTUAL_PATH" }}
|
||||
{{- $nPaths := len $paths }}
|
||||
|
||||
{{- if eq $nPaths 0 }}
|
||||
{{- $paths := groupBy $containers "Env.VIRTUAL_PATH" }}
|
||||
{{- $nPaths := len $paths }}
|
||||
{{- if eq $nPaths 0 }}
|
||||
{{- $paths = dict "/" $containers }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $path, $containers := $paths }}
|
||||
{{- range $path, $containers := $paths }}
|
||||
{{- $upstream := $upstream_name }}
|
||||
{{- if gt $nPaths 0 }}
|
||||
{{- $sum := sha1 $path }}
|
||||
{{- $upstream = printf "%s-%s" $upstream $sum }}
|
||||
{{- end }}
|
||||
# {{ $host }}{{ $path }}
|
||||
{{ template "upstream" (dict "Upstream" $upstream "Containers" $containers "Networks" $CurrentContainer.Networks "Debug" $debug_all) }}
|
||||
{{- end }}
|
||||
# {{ $host }}{{ $path }}
|
||||
{{ template "upstream" (dict "Upstream" $upstream "Containers" $containers "Networks" $CurrentContainer.Networks "Debug" $debug_all) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $default_host := or ($.Env.DEFAULT_HOST) "" }}
|
||||
{{- $default_server := index (dict $host "" $default_host "default_server") $host }}
|
||||
{{- $default_host := or ($.Env.DEFAULT_HOST) "" }}
|
||||
{{- $default_server := index (dict $host "" $default_host "default_server") $host }}
|
||||
|
||||
{{- /* Get the SERVER_TOKENS defined by containers w/ the same vhost, falling back to "" */}}
|
||||
{{- $server_tokens := trim (or (first (groupByKeys $containers "Env.SERVER_TOKENS")) "") }}
|
||||
{{- /* Get the SERVER_TOKENS defined by containers w/ the same vhost, falling back to "" */}}
|
||||
{{- $server_tokens := trim (or (first (groupByKeys $containers "Env.SERVER_TOKENS")) "") }}
|
||||
|
||||
|
||||
{{- /* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}}
|
||||
{{- $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) (or $.Env.HTTPS_METHOD "redirect") }}
|
||||
{{- /* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}}
|
||||
{{- $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) (or $.Env.HTTPS_METHOD "redirect") }}
|
||||
|
||||
{{- /* Get the SSL_POLICY defined by containers w/ the same vhost, falling back to empty string (use default) */}}
|
||||
{{- $ssl_policy := or (first (groupByKeys $containers "Env.SSL_POLICY")) "" }}
|
||||
{{- /* Get the SSL_POLICY defined by containers w/ the same vhost, falling back to empty string (use default) */}}
|
||||
{{- $ssl_policy := or (first (groupByKeys $containers "Env.SSL_POLICY")) "" }}
|
||||
|
||||
{{- /* Get the HSTS defined by containers w/ the same vhost, falling back to "max-age=31536000" */}}
|
||||
{{- $hsts := or (first (groupByKeys $containers "Env.HSTS")) (or $.Env.HSTS "max-age=31536000") }}
|
||||
{{- /* Get the HSTS defined by containers w/ the same vhost, falling back to "max-age=31536000" */}}
|
||||
{{- $hsts := or (first (groupByKeys $containers "Env.HSTS")) (or $.Env.HSTS "max-age=31536000") }}
|
||||
|
||||
{{- /* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}}
|
||||
{{- $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }}
|
||||
{{- /* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}}
|
||||
{{- $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }}
|
||||
|
||||
|
||||
{{- /* Get the first cert name defined by containers w/ the same vhost */}}
|
||||
{{- $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }}
|
||||
{{- /* Get the first cert name defined by containers w/ the same vhost */}}
|
||||
{{- $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }}
|
||||
|
||||
{{- /* Get the best matching cert by name for the vhost. */}}
|
||||
{{- $vhostCert := (closest (dir "/etc/nginx/certs") (printf "%s.crt" $host))}}
|
||||
{{- /* Get the best matching cert by name for the vhost. */}}
|
||||
{{- $vhostCert := (closest (dir "/etc/nginx/certs") (printf "%s.crt" $host))}}
|
||||
|
||||
{{- /* vhostCert is actually a filename so remove any suffixes since they are added later */}}
|
||||
{{- $vhostCert := trimSuffix ".crt" $vhostCert }}
|
||||
{{- $vhostCert := trimSuffix ".key" $vhostCert }}
|
||||
{{- /* vhostCert is actually a filename so remove any suffixes since they are added later */}}
|
||||
{{- $vhostCert := trimSuffix ".crt" $vhostCert }}
|
||||
{{- $vhostCert := trimSuffix ".key" $vhostCert }}
|
||||
|
||||
{{- /* Use the cert specified on the container or fallback to the best vhost match */}}
|
||||
{{- $cert := (coalesce $certName $vhostCert) }}
|
||||
{{- /* Use the cert specified on the container or fallback to the best vhost match */}}
|
||||
{{- $cert := (coalesce $certName $vhostCert) }}
|
||||
|
||||
{{- $is_https := (and (ne $https_method "nohttps") (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert))) }}
|
||||
{{- $is_https := (and (ne $https_method "nohttps") (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert))) }}
|
||||
|
||||
{{- if and $is_https (eq $https_method "redirect") }}
|
||||
{{- if and $is_https (eq $https_method "redirect") }}
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
{{- if $server_tokens }}
|
||||
@ -323,7 +322,7 @@ server {
|
||||
{{- end }}
|
||||
{{ $access_log }}
|
||||
|
||||
# Do not HTTPS redirect Let'sEncrypt ACME challenge
|
||||
# Do not HTTPS redirect Let's Encrypt ACME challenge
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
auth_basic off;
|
||||
auth_request off;
|
||||
@ -341,7 +340,7 @@ server {
|
||||
{{- end }}
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
@ -417,7 +416,7 @@ server {
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
{{- if (and (not $is_https) (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
|
||||
{{- if (and (not $is_https) (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
{{- if $server_tokens }}
|
||||
@ -433,6 +432,6 @@ server {
|
||||
ssl_certificate /etc/nginx/certs/default.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/default.key;
|
||||
}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user