How to route subdomain to a path in docker container using traefik?

  docker, traefik

I have a docker container that has an exposed web service at localhost:8080/foo (no I can’t change it)
When I provide a host for it using traefik I can reach it at bar.domain.com/foo
I would like to reach it a bar.domain.com instead.
I tired replacing the path, adding path, stripping path, but it just redirects it to bar.domain.com/foo or throws a "TO MANY REDIRECTS"

Here is my last config

            "traefik.enable": "true",
            "traefik.http.middlewares.foo_prefix.replacepathregex.regex": "^(.*)",
            "traefik.http.middlewares.foo_prefix.replacepathregex.replacement": "/foo/$$1",
            "traefik.http.routers.service.middlewares": "foo_prefix",
            "traefik.http.routers.service.rule": "Host(`bar.domain.com`)",
            "treafik.http.routers.service.entrypoints": "web"

Any suggestions how to manage internal routing?

Source: Docker Questions

LEAVE A COMMENT