When the need arise to reverse-proxy services, my go-to solution until recently was
Since I've now been introduced to
traefik, the question is a bit more up for debate, but in any case,
the Internet mostly references configuration leveraging the Docker provider of
traefik, with the
which is great, but not always the best solution.
In some situation where you can't or don't want to modify the proxied services'
docker run command line), it's easiest to fall-back to a more classical file-provider to decorelate
traefik's configuration from your services' one.
Here is a starting point configuration doing just that:
version: '3' services: reverse-proxy: image: traefik:v2 volumes: - ./config:/etc/traefik
[entryPoints] [entryPoints.http] address = ":80" [log] level = "INFO" # Activate access logs on stdout [accessLog] # Activate the web UI [api] insecure = true [providers.file] filename = "/etc/traefik/services.toml"
[http] [http.routers] [http.routers.dev-api] service = "dev-api" rule = "Host(`my-dev.host.name`) && PathPrefix(`/api`)" [http.routers.dev] service = "dev" rule = "Host(`my-dev.host.name`) && !PathPrefix(`/api`)" [http.routers.staging] service = "staging" rule = "Host(`my-staging.host.name`)" [http.services] [http.services.dev-api] [http.services.dev-api.loadBalancer] [[http.services.dev-api.loadBalancer.servers]] url = "http://10.0.0.1:4001/" [http.services.dev] [http.services.dev.loadBalancer] [[http.services.dev.loadBalancer.servers]] url = "http://10.0.0.1:4000/" [http.services.staging] [http.services.staging.loadBalancer] [[http.services.staging.loadBalancer.servers]] url = "http://10.0.0.2:4000/"