Load Balancing with NGINX Exmaple not Working

Hi, I tried load-balancing-nginx on my local maschine:

Linux: 5.11.11-arch1-1
Docker: 20.10.5

I started Consul and Nomad in Dev mode. When I read the rendered config I see:

nomad alloc fs acb nginx/local/load-balancer.conf

Summary

upstream backend {

server 127.0.0.1:20242;

server 127.0.0.1:22908;

server 127.0.0.1:31949;

}

server {
listen 8080;

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

That obviously does not work. Tthe forward in the Ngix contianer does not work because it is trying to forward to 127.0.0.1.

Does anyone has an idea how to solve that?

Regards,
Alfred

1 Like

Hi @Alfred,

When running Nomad and Consul in dev mode, they both will bind and advertise on localhost which is causing the problems you are seeing. In order to update this and thus resolve the problem I would suggest passing the Nomad bind_addr and Consul bind_addr when starting the applications. Alternatively the Learn guide details this Terraform setup that will provide you with a cluster configured in the desired manner.

Thanks,
jrasell and the Nomad team

1 Like

Hi,

I’m in the early stages of evaluating nomad so I’m a “noob” (something my 2 young boys would say).

I binded to 0.0.0.0 for both nomad & consul so they aren’t using the loopback address but I too cannot get the example to work. I understand why but is there something I can do locally to get beyond this?

Warmest regards,

Garrard