This commit is contained in:
SilverFire - Dmitry Naumenko 2022-04-22 14:15:02 +03:00
parent c0cfab2c14
commit bbac3c93aa

View file

@ -269,32 +269,29 @@ server {
{{ $paths := groupBy $containers "Env.VIRTUAL_PATH" }} {{ $paths := groupBy $containers "Env.VIRTUAL_PATH" }}
{{ $nPaths := len $paths }} {{ $nPaths := len $paths }}
{{ $paths := groupBy $containers "Env.VIRTUAL_PATH" }}
{{ $nPaths := len $paths }}
{{ if eq $nPaths 0 }} {{ if eq $nPaths 0 }}
# {{ $host }} # {{ $host }}
{{ template "upstream" (dict "Upstream" $upstream_name "Containers" $containers "Networks" $CurrentContainer.Networks "Debug" $debug_all) }} {{ template "upstream" (dict "Upstream" $upstream_name "Containers" $containers "Networks" $CurrentContainer.Networks "Debug" $debug_all) }}
{{ else }} {{ else }}
{{ range $path, $containers := $paths }} {{ range $path, $containers := $paths }}
{{ range $container := $containers }} {{ range $container := $containers }}
{{ $addrLen := len $container.Addresses }} {{ $addrLen := len $container.Addresses }}
{{ range $knownNetwork := $CurrentContainer.Networks }} {{ range $knownNetwork := $CurrentContainer.Networks }}
{{ range $containerNetwork := $container.Networks }} {{ range $containerNetwork := $container.Networks }}
{{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }} {{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
## Can be connected with "{{ $containerNetwork.Name }}" network ## Can be connected with "{{ $containerNetwork.Name }}" network
{{ $sum := sha1 $path }} {{ $sum := sha1 $path }}
{{ $upstream := printf "%s-%s" $upstream_name $sum }} {{ $upstream := printf "%s-%s" $upstream_name $sum }}
# {{ $host }}{{ $path }} # {{ $host }}{{ $path }}
{{ template "upstream" (dict "Upstream" $upstream "Containers" $containers "Networks" $CurrentContainer.Networks "Debug" $debug_all) }} {{ template "upstream" (dict "Upstream" $upstream "Containers" $containers "Networks" $CurrentContainer.Networks "Debug" $debug_all) }}
{{ else }} {{ else }}
# Cannot connect to network of this container # Cannot connect to network of this container
server 127.0.0.1 down; server 127.0.0.1 down;
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}