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

**URL:** <https://community.traefik.io/t/traefik-docker-swarm-adding-trailing-slash-to-docker-compose-yml/12326>\
**Category:** Traefik v2\
**Tags:** docker-swarm\
**Created:** [November 3, 2021, 1:22pm UTC](https://community.traefik.io/t/traefik-docker-swarm-adding-trailing-slash-to-docker-compose-yml/12326 "2021-11-03T13:22:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardtc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/richardtc/32/4458_2.png) [@richardtc](https://community.traefik.io/u/richardtc)\
**Post date:** [November 3, 2021, 1:22pm UTC](https://community.traefik.io/t/traefik-docker-swarm-adding-trailing-slash-to-docker-compose-yml/12326/1 "2021-11-03T13:22:16Z")

</div>

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/](http://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

---

<div class="post-metadata">

**Author:** ![jakubhajek](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jakubhajek/32/3389_2.png) [@jakubhajek](https://community.traefik.io/u/jakubhajek)\
**Post date:** [November 9, 2021, 11:13pm UTC](https://community.traefik.io/t/traefik-docker-swarm-adding-trailing-slash-to-docker-compose-yml/12326/2 "2021-11-09T23:13:00Z")

</div>

Hello @richardtc

Thanks for using Traefik and asking the question.

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

- [stripprefix](https://doc.traefik.io/traefik/middlewares/http/stripprefix/)
- [redirectregex](https://doc.traefik.io/traefik/middlewares/http/redirectregex/)

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,
