OVERVIEW
Nginx runs in Docker container, also NodeJS application (worker) runs in another one, all managed by Docker Compose. Configuration has an upstream: container of worker 1 is also up and running, while node with worker 2 is not.
upstream nodeapp {
server appconfig_host-nodejs-app-worker_1:3000;
server appconfig_host-nodejs-app-worker_2:3000;
}
It is then used in location block to proxy pass all requests.
location /api/ {
proxy_pass http://nodeapp/;
}
ACTUAL RESULT
When worker 2 is in configuration (the container which is not running), I got error [emerg] 1#1: host not found in upstream "appconfig_host-nodejs-app-worker_2:3000"
and container exits with code 1.
When I remove line with second worker from upstream configuration, and keep just worker 1, then everything works just fine, proxy works as expected, serving my NodeJS app at /localhost/api/
.
EXPECTED RESULT
I'd expect Nginx built-in balancing working so that it holds sending requests to worker 2, until it is alive again. I.e. service operates normally, not having worker 2 in the upstream, so all requests go to worker 1.
Please advise what might be wrong here, as I could not find any way to fix that for few hours already. Thanks a lot in advance.