Creating a reverse proxy service in charge of routing requests depending on their base URLs
We can implement a reverse proxy in a couple of ways. One would be to create a new image based on HAProxy (https://hub.docker.com/_/haproxy/) and include configuration files inside it. That approach would be a good one if the number of different services is relatively static. Otherwise, we'd need to create a new image with a new configuration every time there is a new service (not a new release). The second approach would be to expose a volume. That way, when needed, we could modify the configuration file instead building a whole new image. However, that has downsides as well. When Deploying to a cluster, we should avoid using volumes whenever they're not necessary. As you'll see soon, a proxy is one of those that do not require a volume. As a side note, --volume
has been replaced with the docker service
argument --mount
.
The third option is to use one of the proxies designed to work with Docker Swarm...