diff --git a/templates/haproxy.cfg.tmpl b/templates/haproxy.cfg.tmpl index bed02a23aa83932138992ba1f2410bec4a017f82..6a754dd2c2093199d8d8250b1b45603fb4225f94 100644 --- a/templates/haproxy.cfg.tmpl +++ b/templates/haproxy.cfg.tmpl @@ -43,8 +43,17 @@ backend {{ $host }} option http-server-close cookie SERVERID insert nocache indirect {{ range $container := $containers }} - {{ $network := index $container.Networks 0 }} + {{ $networkLen := len $container.Networks }} + {{ if eq $networkLen 1 }} + {{ $network := index $container.Networks 0 }} server Server {{ $network.IP }}:80 cookie Server + {{ else }} + {{ range $network := $container.Networks }} + {{ if eq $network.Name "lb_web" }} + server Server {{ $network.IP }}:80 cookie Server + {{end}} + {{end}} + {{end}} {{end}} {{end}}