1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2024-11-25 13:26:30 +00:00

Fix template error when /etc/nginx/certs does not exist

This commit is contained in:
Jason Wilder 2016-06-12 13:11:45 -06:00
parent adf4573de4
commit 9c93efaef9

View File

@ -112,11 +112,13 @@ upstream {{ $host }} {
{{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }} {{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }}
{{/* Get the best matching cert by name for the vhost. */}} {{/* Get the best matching cert by name for the vhost. */}}
{{ $vhostCert := "" }}
{{ if exists "/etc/nginx/certs" }}
{{ $vhostCert := (closest (dir "/etc/nginx/certs") (printf "%s.crt" $host))}} {{ $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 is actually a filename so remove any suffixes since they are added later */}}
{{ $vhostCert := replace $vhostCert ".crt" "" -1 }} {{ $vhostCert := replace $vhostCert ".crt" "" -1 }}
{{ $vhostCert := replace $vhostCert ".key" "" -1 }} {{ $vhostCert := replace $vhostCert ".key" "" -1 }}
{{ end }}
{{/* Use the cert specifid on the container or fallback to the best vhost match */}} {{/* Use the cert specifid on the container or fallback to the best vhost match */}}
{{ $cert := (coalesce $certName $vhostCert) }} {{ $cert := (coalesce $certName $vhostCert) }}