Traefik, Docker Swarm: adding trailing slash to docker-compose.yml

Hi,

I'm trying to append a path and trailing slash to the URL of a Shiny app.

I can append a path to the domain name using the PathPrefix syntax as follows (from the docker-compose.yml file):

  deploy:
       replicas: 5
       labels:
         - "traefik.enable=true"
         - "traefik.http.routers.dataservice.entrypoints=web"
         - "traefik.http.routers.dataservice.rule= Host(`en.localexample.com`) && PathPrefix(`/9c9t/`)" 
         - "traefik.http.middlewares.dataservice.stripprefix.prefixes=/9c9t"
         -  traefik.http.routers.dataservice.middlewares=dataservice@docker"

However, I need to retain the trailing slash for the Shiny app to show (i.e., en.localexample.com/9c9t/)

I'm having trouble adding a trailing slash. I've tried the following and other regex expressions/traefik code, but it does not work:

     - traefik.http.middlewares.dataservice.redirectregex.regex="https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*9c9t)$$"
     - traefik.http.middlewares.dataservice.redirectregex.replacement="https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*9c9t)$${1}/9c9t/"  

With the above I get an error such as the following (as seen in the Traefik web app):

      cannot create middleware: multi-types middleware not supported, consider declaring two     different pieces of middleware instead

I'm not sure what this error means.

Anyhow, I'd be grateful for any suggestions on how to add a trailing slash to the Prefix path.

Thanks,
Richard

Traefik version 2.5.3
Docker version 20.10.10, build b485636

Hello @richardtc

Thanks for using Traefik and asking the question.

The issue is that you have defined the same names for the two middlewares:

The names should be different and then append the middleware to your router. Please follow the documentation I linked, the names defined in the docs can be used in your configuration.

Thank you,