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
I would like to reach it a instead.
I tired replacing the path, adding path, stripping path, but it just redirects it to 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(``)",
            "treafik.http.routers.service.entrypoints": "web"

Any suggestions how to manage internal routing?

Source: Docker Questions