Score:0

Nginx proxy is not finding the backend services

th flag

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;
    }
}
djdomi avatar
za flag
use ips instead of names
Nico Gatti avatar
th flag
is there a reason why? I understand it shoud work with names
djdomi avatar
za flag
`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?
Score:0
th flag

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.