Expose containers using host networking if they have their VIRTUAL_PORT variable set

This commit is contained in:
Ondrej Perutka 2022-05-20 15:32:59 +02:00
parent c4ad18fecc
commit f97e759105

View file

@ -125,6 +125,10 @@ upstream {{ .Upstream }} {
{{ if $containerNetwork.IP }} {{ if $containerNetwork.IP }}
{{ $server_found = "true" }} {{ $server_found = "true" }}
server {{ $containerNetwork.IP }}:{{ $port }}; 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 }} {{ else }}
# /!\ No IP for this network! # /!\ No IP for this network!
{{ end }} {{ end }}