From 0b98ba02bed6662617ff45d642c258911d9dddf6 Mon Sep 17 00:00:00 2001 From: Marc Carmier Date: Sat, 13 Feb 2016 22:35:49 +0100 Subject: [PATCH 1/3] Basic index.html lists the active proxied virtual hosts --- index.tmpl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 index.tmpl 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 }}

+
+ +
+ + From 8ddf56babc140fc60fa450266c928a65e1b17201 Mon Sep 17 00:00:00 2001 From: Marc Carmier Date: Sat, 13 Feb 2016 22:44:05 +0100 Subject: [PATCH 2/3] generate a index.html from index.tmpl --- Procfile | 3 ++- nginx.tmpl | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) 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/nginx.tmpl b/nginx.tmpl index 255cc35..08a947d 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -55,7 +55,10 @@ 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; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } } {{ if (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }} @@ -63,7 +66,10 @@ 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; + 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; From 326c28899d9c321899de163c45e0a93a59d4eefe Mon Sep 17 00:00:00 2001 From: Marc Carmier Date: Sat, 13 Feb 2016 23:15:41 +0100 Subject: [PATCH 3/3] Limit the list page to the URL from INDEX_HOST variable --- nginx.tmpl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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" "," }}