From ea86a04638dea6719d280502b45a2aeb151c4590 Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Sat, 3 Jan 2015 16:39:56 +0100 Subject: [PATCH] Display a list of discovered virtual hosts --- Procfile | 1 + index.html.tmpl | 13 +++++++++++++ nginx.tmpl | 5 ++++- www/index.html | 6 ++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 index.html.tmpl create mode 100644 www/index.html diff --git a/Procfile b/Procfile index 8547156..b465435 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 +dockergen: docker-gen -watch -only-exposed /app/index.html.tmpl /app/www/index.html diff --git a/index.html.tmpl b/index.html.tmpl new file mode 100644 index 0000000..e108ce2 --- /dev/null +++ b/index.html.tmpl @@ -0,0 +1,13 @@ +

Nginx Reverse Proxy for Docker

+ +{{ with groupByMulti $ "Env.VIRTUAL_HOST" "," }} + +{{ else }} +

The Nginx Reverse Proxy for Docker is started but no virtual hosts have been found. Try starting one with the VIRTUAL_HOST environement variable set.

+
$ docker run --rm --name helloworld --expose 8080 -e VIRTUAL_HOST=helloworld.127.0.0.1.xip.io adejonge/helloworld
+

More information on Github

+{{ end }} diff --git a/nginx.tmpl b/nginx.tmpl index fd5d2e9..6baeeca 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -34,7 +34,10 @@ proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto; server { listen 80 default_server; server_name _; # This is just an invalid value which will never trigger on a real hostname. - return 503; + location / { + root /app/www/; + } + error_page 404 /; } {{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }} diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..2562861 --- /dev/null +++ b/www/index.html @@ -0,0 +1,6 @@ +

Nginx Reverse Proxy for Docker

+ +

+ The Nginx Reverse Proxy for Docker has not yet started. + More information on Github +