# Traefik Swarm Mode + StripPrefix seems to not work as intended

**URL:** <https://community.traefik.io/t/traefik-swarm-mode-stripprefix-seems-to-not-work-as-intended/10640>\
**Category:** Traefik v2\
**Tags:** docker-swarm, middleware, docker\
**Created:** [May 17, 2021, 2:45pm UTC](https://community.traefik.io/t/traefik-swarm-mode-stripprefix-seems-to-not-work-as-intended/10640 "2021-05-17T14:45:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChtiSeb\_Premista](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/chtiseb_premista/32/3792_2.png) [@ChtiSeb\_Premista](https://community.traefik.io/u/ChtiSeb_Premista)\
**Post date:** [May 17, 2021, 2:45pm UTC](https://community.traefik.io/t/traefik-swarm-mode-stripprefix-seems-to-not-work-as-intended/10640/1 "2021-05-17T14:45:26Z")

</div>

Hi there,

I'm looking to strip path prefix before sending it to my docker services.

Currently I'm launching the Traefik in a swarm mode also are my Docker Services.

Traefik configuration :

```auto
            "Name": "traefik_traefik",
            "Labels": {
                "com.docker.stack.image": "traefik:v2.4.8",
                "com.docker.stack.namespace": "traefik"
            },
            "TaskTemplate": {
                "ContainerSpec": {
                    "Image": "traefik:v2.4.8@sha256:08d8a7759f5fffa2441488151cedcd4d556c1f124c097f929f469c1f7b82c16f",
                    "Labels": {
                        "com.docker.stack.namespace": "traefik"
                    },
                    "Args": [
                        "--log.level=DEBUG",
                        "--api.dashboard=true",
                        "--providers.docker.swarmMode=true",
                        "--api.insecure=true",
                        "--providers.docker=true",
                        "--providers.docker.exposedbydefault=false",
                        "--entrypoints.web.address=:80",
                        "--entrypoints.websecure.address=:443",
                        "--certificatesresolvers.myresolver.acme.httpchallenge=true",
                        "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web",
                        "--certificatesresolvers.myresolver.acme.caserver=https://acme-v02.api.letsencrypt.org/directory",
                        "--certificatesresolvers.myresolver.acme.email= ***@***.***",
                        "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
                    ],

```

My Service which must answer to [domain.com/api/my\_service/](http://domain.com/api/my_service/) and forward to the service as : /

```auto
        "Spec": {
            "Name": "my_service",
            "Labels": {
                "com.docker.stack.image": "company/my_service:version",
                "com.docker.stack.namespace": "my_namespace",
                "traefik.docker.network": "my_network",
                "traefik.enable": "true",
                "traefik.http.middlewares.stripprefix-my_service.stripprefix.prefixes": "/api/my_service",
                "traefik.http.routers.template_api_recette.entrypoints": "websecure",
                "traefik.http.routers.template_api_recette.rule": "(Host(`domain.com`) \u0026\u0026 PathPrefix(`/api/my_service`))",
                "traefik.http.routers.template_api_recette.tls.certresolver": "myresolver",
                "traefik.http.services.template_api_recette.loadbalancer.server.port": "80",
                "traefix.http.routers.template_api_recette.middlewares": "stripprefix-my_service"
            },

```

Actually, with this configuration, I only manage to redirect the request received by Traefik to my service, but without the prefix stripping, so my service return a 500 because it can't find the /api/my\_service URI.

What do I do wrong with this configuration ? I tried several other configuration, adding a @docker to my middleware without any success and currently I'm going crazy trying to resolve this situation and I do not want to alter my service by giving it the prefix I use (should work, but before I used a simple NGINX proxy and it work well, stripping this prefix before querying the service).

I may have misunderstood some of configuration step in Traefik.

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [May 17, 2021, 3:44pm UTC](https://community.traefik.io/t/traefik-swarm-mode-stripprefix-seems-to-not-work-as-intended/10640/2 "2021-05-17T15:44:28Z")

</div>

> [@ChtiSeb\_Premista](#):
>
> ` "traefix.http.routers.template_api_recette.middlewares": "stripprefix-my_service"`

You have `traefix` it should be `traefik`

---

<div class="post-metadata">

**Author:** ![ChtiSeb\_Premista](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/chtiseb_premista/32/3792_2.png) [@ChtiSeb\_Premista](https://community.traefik.io/u/ChtiSeb_Premista)\
**Post date:** [May 17, 2021, 9:21pm UTC](https://community.traefik.io/t/traefik-swarm-mode-stripprefix-seems-to-not-work-as-intended/10640/3 "2021-05-17T21:21:41Z")

</div>

Thanks a lot @cakiwi ... It is a frequent error I do while typing on the keyboard and this one pass through every reading of the configuration. I was really "close" to the solution, but your help was wonderful.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [May 20, 2021, 9:22pm UTC](https://community.traefik.io/t/traefik-swarm-mode-stripprefix-seems-to-not-work-as-intended/10640/4 "2021-05-20T21:22:20Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
