Frontend and API in different containers
I have 3 containers for each (Frontend, backend and MongoDB)
- Frontend, expose port:
0.0.0.0:80->80/tcp, 443/tcp
- API, expose ports:
80/tcp, 443/tcp, 43554/tcp, 0.0.0.0:3000->3000/tcp
- MongoDB, expose ports:
0.0.0.0:27017->27017/tcp
To run my API, I just link the MongoDB container
docker run -d -p 3000:3000 --name backend --link mongodb:mongodb backend
In my frontend app, every ajax call will do by /api/
So ...
Front-end (HTML/CSS/JS) make a request to /api/***
, and should redirect to container port :3000
so my API can respond.
How can I do that? both using same url myapp.com
for front-end and myapp.com/api
for backend.