I have a document at my.host.com/foo/bar/docpath
, and I want it to be available at the url my.host.com/docpath
. All my Traefik config is in a docker-compose file.
This is the config in my service's container :
labels:
traefik.enable: "true"
traefik.http.routers.myservice.entrypoints: secure
traefik.http.routers.myservice.middlewares: rewritepath
traefik.http.routers.myservice.rule: "Host(`my.host.com`) && Path(`/docpath`)"
and in the Traefik's container labels :
labels:
traefik.http.middlewares.rewritepath.addprefix.prefix: /foo/bar
Problem : when I request my.host.com/docpath
, I have a 404 error. What do I do wrong ?
(given that I access correctly to my.host.com/foo/bar/docpath
with a simple rule: "Host(`my.host.com`)" and no middleware)
My understanding of traefik is, that middlewares are called after rules.
Try this.
- "traefik.http.routers.myservice.rule: "Host(`my.host.com`) && Path(`/docpath`)"
- "traefik.http.routers.myservice.middlewares=rewritepath"
- "traefik.http.middlewares.rewritepath.addprefix.prefix=/foo/bar"