I'm trying to build a multi-container environment, with a client,server,worker & nginx directories and I'm getting this error:
nginx_1 | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx_1 | 2021/01/01 19:48:26 [emerg] 1#1: host not found in upstream "client:3000" in /etc/nginx/conf.d/default.conf:2
nginx_1 | nginx: [emerg] host not found in upstream "client:3000" in /etc/nginx/conf.d/default.conf:2
Why it can't find my react service running on
3000
in my latest check the default port has not been changed
Architecture
- Client: React project listens on default port
3000
- Server: The
API
server listens on port5000
- Worker: functions in a
js
file - Nginx: contains the
default.conf
andDockerfile.dev
(Dockerfile.dev is not omitted in the previous directories) - Some more backend services
Nginx
This is my configuration where i try to forward requests from /
to client and from /api
to the server
default.conf
upstream client {
server client:3000;
}
upstream api {
server api:5000;
}
server {
listen 80;
location / {
proxy_pass http://client;
}
locatoin /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://api;
}
}
docker-composer.yml
version: '3'
services:
nginx:
restart: always
build:
dockerfile: Dockerfile.dev
context: ./nginx
ports:
- '8081:80'
Dockerfile.dev
FROM nginx
COPY ./default.conf /etc/nginx/conf.d/default.conf