Traefik Swarm Mode + StripPrefix seems to not work as intended

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 :

            "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": [

My Service which must answer to and forward to the service as : /

        "Spec": {
            "Name": "my_service",
            "Labels": {
                "com.docker.stack.image": "company/my_service:version",
                "com.docker.stack.namespace": "my_namespace",
                "": "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(``) \u0026\u0026 PathPrefix(`/api/my_service`))",
                "traefik.http.routers.template_api_recette.tls.certresolver": "myresolver",
                "": "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.

You have traefix it should be traefik

1 Like

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.

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