0

I've an installation with 2 backend services that should be proxied by a third Nginx service.

I've deployed the 3 services succesfully but for some reason I can't get nginx to see the other 2 services giving the error:

GET / HTTP/1.1" 502 560

and

[error] 8#8: *1 no live upstreams while connecting to upstream

I have tried changing all the services to their own network but it seems the issue is not solved.

Adding my docker-compose.yml:

version: "3"
services:
    nginx_web_1:
        image: nginx:1.17
        volumes:
            - "./files_1:/usr/share/nginx/html:ro"

    nginx_web_2:
        image: nginx:1.17
        volumes:
            - "./files_2:/usr/share/nginx/html:ro"

    nginx_balancer:
        build: ./balancer
        ports:
            - 5000:80
        depends_on:
            - nginx_web_1
            - nginx_web_2

and this is how I configured the proxy:

File moved to /etc/nginx/conf.d/default.conf

upstream backend_hosts {
    server nginx_web_1;
    server nginx_web_2;
}

server {
    listen 80;
    server_name localhost;
    location / {
      proxy_pass http://backend_hosts;
    }
}
  • use ips instead of names – djdomi Jun 22 '21 at 16:51
  • is there a reason why? I understand it shoud work with names – Nico Gatti Jun 22 '21 at 21:42
  • `no live upstreams while connecting to upstream` looks to me he cant resolv or find it - it get it without name resolution errors, use ips to debug - thats the first point, the second, does the container listen to port 80? – djdomi Jun 23 '21 at 04:14

1 Answers1

0

After some investigation, the issue was that I was running only docker-compose up/down which didn't rebuild my Nginx proxy image.

After cleaning up and running a docker build the proxy was configured properly and now runs fine.

That means that also the config listed in the question is a valid one