From aced41a3d25da286b13997def220a45fd9a03da2 Mon Sep 17 00:00:00 2001 From: Jana Radhakrishnan Date: Thu, 4 Aug 2016 17:39:38 -0700 Subject: [PATCH] Make service LB work from self Make service loadbalancing to work from within one of the containers of the service. Currently this only works when the loadbalancer selects the current container. If another container of the same service is chosen, the connection times out. This fix adds a SNAT rule to change the source IP to the containers primary IP so that responses can be routed back to this container. Signed-off-by: Jana Radhakrishnan --- libnetwork/service_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnetwork/service_linux.go b/libnetwork/service_linux.go index 7c5fb6fc88..e0cf64bda9 100644 --- a/libnetwork/service_linux.go +++ b/libnetwork/service_linux.go @@ -710,7 +710,7 @@ func fwMarker() { os.Exit(4) } - if len(ingressPorts) != 0 && addDelOpt == "-A" { + if addDelOpt == "-A" { ruleParams := strings.Fields(fmt.Sprintf("-m ipvs --ipvs -j SNAT --to-source %s", os.Args[6])) if !iptables.Exists("nat", "POSTROUTING", ruleParams...) { rule := append(strings.Fields("-t nat -A POSTROUTING"), ruleParams...)