how to setup nginx config to make from react js to communicate with node js in docker

  docker, nginx, node.js, reactjs

I am trying to dockerize my personal application. Usually in local we mention the server(http://server:4000) in the package.json file of react. But in production when we build the react app , we don’t use pacakge.json. We have to config the nginx server to redirect the api calls to my node js server.

Here is my nginx config and my containers.

Containers:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
10b8d0bf6b2e abc/client:latest "/docker-entrypoint.…" 43 minutes ago Up 27 minutes 0.0.0.0:8001->80/tcp, :::8001->80/tcp
client
ed73637b394d abc/api:latest "node index.js" 5 days ago Up 39 minutes 0.0.0.0:4000->4000/tcp, :::4000->4000/tcp
node
6ead7807604a mongo "docker-entrypoint.s…" 6 days ago Up 42 minutes 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp
db

Source: Docker Questions

LEAVE A COMMENT