From f36ca3d7a37d6bcd148c6b5e2e77f446fe9b470c Mon Sep 17 00:00:00 2001 From: Mike Dillon Date: Tue, 23 Jun 2015 17:05:12 -0700 Subject: [PATCH] Prevent generating broken config Fixes #115 --- Dockerfile | 2 +- nginx.tmpl | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1b90965..abfae74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf \ RUN wget -P /usr/local/bin https://godist.herokuapp.com/projects/ddollar/forego/releases/current/linux-amd64/forego \ && chmod u+x /usr/local/bin/forego -ENV DOCKER_GEN_VERSION 0.3.9 +ENV DOCKER_GEN_VERSION 0.4.0 RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \ && tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \ diff --git a/nginx.tmpl b/nginx.tmpl index f674b49..70c8ba0 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -58,11 +58,13 @@ upstream {{ $host }} { {{ end }} {{/* Else default to standard web port 80 */}} {{ else }} - {{ range $address := $container.Addresses }} - {{ if eq $address.Port "80" }} + {{ $address := where $container.Addresses "Port" "80" | first }} + {{ if $address }} # {{$container.Name}} - server {{ $address.IP }}:{{ $address.Port }}; - {{ end }} + server {{ $address.IP }}:80; + {{ else }} + # {{$container.Name}} + server {{ $container.IP }} down; {{ end }} {{ end }} {{ end }}