From f97e75910537ce0896dc54fd4b2a00da45ec639b Mon Sep 17 00:00:00 2001 From: Ondrej Perutka Date: Fri, 20 May 2022 15:32:59 +0200 Subject: [PATCH] Expose containers using host networking if they have their VIRTUAL_PORT variable set --- nginx.tmpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nginx.tmpl b/nginx.tmpl index e8a555d..f0c6960 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -125,6 +125,10 @@ upstream {{ .Upstream }} { {{ if $containerNetwork.IP }} {{ $server_found = "true" }} server {{ $containerNetwork.IP }}:{{ $port }}; + {{/* The container is in the host network and wants to be exposed */}} + {{ else if (and $container.Env.VIRTUAL_PORT (eq $containerNetwork.Name "host")) }} + {{ $server_found = "true" }} + server 127.0.0.1:{{ $port }}; {{ else }} # /!\ No IP for this network! {{ end }}