diff --git a/nginx.tmpl b/nginx.tmpl index 08a947d..87df405 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -55,17 +55,37 @@ server { server_name _; # This is just an invalid value which will never trigger on a real hostname. listen 80; access_log /var/log/nginx/access.log vhost; + return 503; +} + +{{ if $.Env.INDEX_HOST }} +server { + server_name {{$.Env.INDEX_HOST}}; # The local site + listen 80; + access_log /var/log/nginx/access.log vhost; location / { root /usr/share/nginx/html; index index.html index.htm; } } +{{ end }} {{ if (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }} server { server_name _; # This is just an invalid value which will never trigger on a real hostname. listen 443 ssl http2; access_log /var/log/nginx/access.log vhost; + return 503; + + ssl_certificate /etc/nginx/certs/default.crt; + ssl_certificate_key /etc/nginx/certs/default.key; +} + +{{ if $.Env.INDEX_HOST }} +server { + server_name {{$.Env.INDEX_HOST}}; # The local site + listen 443 ssl http2; + access_log /var/log/nginx/access.log vhost; location / { root /usr/share/nginx/html; index index.html index.htm; @@ -75,6 +95,7 @@ server { ssl_certificate_key /etc/nginx/certs/default.key; } {{ end }} +{{ end }} {{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}