diff --git a/Procfile b/Procfile index 8547156..d9aca09 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,3 @@ nginx: nginx -dockergen: docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf +gennginx: docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf +genindex: docker-gen -watch -only-exposed /app/index.tmpl /usr/share/nginx/html/index.html diff --git a/index.tmpl b/index.tmpl new file mode 100644 index 0000000..e25e49e --- /dev/null +++ b/index.tmpl @@ -0,0 +1,25 @@ +{{ $title := or $.Env.TITLE "List of proxied sites" }} + + + + + {{ $title }} + + + +

{{ $title }}

+
+ +
+ + diff --git a/nginx.tmpl b/nginx.tmpl index 255cc35..87df405 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -55,19 +55,46 @@ 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; + 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; + 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; + } + + ssl_certificate /etc/nginx/certs/default.crt; + ssl_certificate_key /etc/nginx/certs/default.key; +} +{{ end }} {{ end }} {{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}