Redirect to particular host depending on PATH

Hi,

I have Traefik serving up multiple docker services (listmonk, matrix, matrixmmr) with SSL. They are listed like service.domain.com. So listmonk.domain.com, matrix.domain.com, matrixmmr.domain.com. Each have their own docker internal IP.

I'm trying to make Traefik route to a particular host depending on the PATH requested.

So if requesting matrix.domain.com/_matrix I would like to pass that to "matrix.domain.com"
If requesting matrix.domain.com/_matrix/media I would like to pass that internally to the docker host "matrixmmr.domain.com"

Im aware of using PathPrefix, have used it before, but how do I re-direct based on the host and path from the beginning of the request from Traefik? Do I put them in the main Traefik docker service labels?

Thanks for any help

Regarding naming, a "redirect" is a http response to the client to visit a different address.

Sure you can do that with Docker labels on the according target containers:

      - traefik.http.routers.matrix.rule=Host(`matrix.example.com`) && PathPrefix(`/_matrix`)

      - traefik.http.routers.media.rule=Host(`matrix.example.com`) && PathPrefix(`/_matrix/media`)

The 2nd one will be matched first, it has a higher priority because it is longer (more characters).