Traefik doens't append prefix in redirect request 301

Good morning, I'm using Traefik in a Docker environment with a Django backend. The issue I'm facing is that when I enter a URL like localhost/service/test/ , I get a 200 response and everything works fine. However, when I enter localhost/service/test (without the trailing slash), I receive a 301 redirect and Traefik redirects me to localhost/test/ . How can I maintain the prefix? Below is my app configuration:


deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.constraint-label=cloud-public"
        - "traefik.http.services.service.loadbalancer.server.port=8000"
        - "traefik.http.routers.service.entrypoints=web"
        - "traefik.http.routers.service.rule=PathPrefix(`/service`)"
        - "traefik.http.routers.service.middlewares=service-stripprefix"
        - "traefik.http.routers.service.tls=false"
        - "traefik.http.middlewares.service-stripprefix.stripprefix.prefixes=/service,/service/"
  database:


Thank you!

Why would Traefik send the redirect? I would think this is from your application. It does not like /test so it sends you to /test/.

You can run something like traefik/whoami to check how the request looks like at the target and if the redirect still happens.

Note that web-apps are usually not "path aware", they will send responses with "/"-based links (redirect, script, image, links), that do not work with a path you try to remove with middleware stripprefix. This only works if you can tell your app something like an external "base path".

Note that constraint-label does not seem to exist according to the Traefik Docker reference.