Nomad load balancer tutorials - nginx not binding to all interfaces

Hello,

We have been experimenting with Nomad for production workloads for clients over the last 2 weeks.

We now have Nomad running with Consul in a cluster, we’ve refactored our containers and are pretty happy with running job’s etc.

When running through the tutorials we’ve found the following results

HAPROXY - Does not work, always returns 503 on the demo job. Could not get this to run.

Fabio - This ran and we have our own backend service using it. Fabio bound to all IP’s on the nomad client system on port 9999.

Traefick - This ran and bound to all IP’s on the nomad client system on port 8080.

Nginx - This ran and we had the best results, however it only seems to bind to the public IP on the nomad client machine. Despite consulting the documentation and a lot of forums we cannot seem to get this job to run on all IP’s. We are using this with a DigitalOcean load balancer infront of and the DO load balancer uses the private VPC IP’s.

My question is what do I need to change in this job file to make nginx bind to all IP’s like Fabio and Traefik do?

job “nginx” {
datacenters = [“dc1”]
type = “system”
group “nginx” {
count = 1
task “nginx” {
driver = “docker”

  config {
image = "nginx"

    port_map {
      http = 80
    }

volumes = [
      "local:/etc/nginx/conf.d",
    ]
 }

  template {
    data = <<EOF
    upstream backend {
    {{ range service "my-fe-service" }}
    server {{ .Address }}:{{ .Port }};
    {{ else }}server 127.0.0.1:65535; # force a 502
    {{ end }}
}

server {
listen 80;

location / {
proxy_pass http://backend;
}
}
EOF

    destination   = "local/load-balancer.conf"
    change_mode   = "signal"
    change_signal = "SIGHUP"
  }

  resources {
    network {
      mbits = 10
     port "http" {
    static = 8080
      }

    }
  }

  service {
    name = "nginx"
    port = "http"
  }
}

}
}

1 Like

Good question. I am also wondering why these various reverse-proxies behave so differently! Anyhow to answer your question, I believe we will be able to resolve this issue in the near future with: Multi-Interface Networking

However, for me, i was slightly disappointed that I could not get a consistent HAProxy, but Fabio appears to performing quite well.