Docker Community Forums

Share and learn in the Docker community.

Docker URL redirects

Hello All,

I am trying to create a docker setup in which http requests sent from an angular app to an express server both running on localhost:8080. These request’s urls have slugs prefixed with /api/. When this code is released, these routes are sent through a proxy and redirected to another site where the /api prefix is removed from the url. When running locally using docker I would like to mimic that behavior by rerouting any requests sent to localhost:8080/api/ to localhost:8080/. What is the best way to do this within docker? Should I create another docker service to act as a proxy within the containers’ bridge network or is there another (possibly easier) way?

Disclaimer** I know this could be easily be done as a solution within the angular app itself to change behavior when running locally. However, I would like to have the behavior of the angular app remain the same across all environments if possible.

Hint: each container will use it’s own, seperate namespace for the network interface. Thus, accessing another containers port from another container using localhost does not work. Localhost inside a container is local to the container…

What prevents you from adapting the existing solution to the container world?