I am using Traefik with Docker Swarm to forward network traffic to one of my webserver containers based on the Headers rule. The header information should be extracted from a jwt. I have used a middleware plugin developed by lion7 (GitHub - lion7/traefik-jwt-headers-plugin: Traefik middleware plugin which forwards JWT claims as request headers) for this. Here are the labels which I mentioned in my webserver deployment playbook file:
labels: traefik.enable: "true" traefik.http.routers.myrouter.entrypoints: aio traefik.http.routers.myrouter.rule: "Headers(`X-Jwt-Tenant`, `123456`)" traefik.http.routers.myrouter.middlewares: my-jwt-plugin@file traefik.http.services.webserver.loadbalancer.server.port: 8081
where 8081 is the exposed port of my webserver container. The problem is, the Traefik rule is evaluated "before" any middleware has the opportunity to work, and I only have the header information “after” the middleware is doing its job and as a result, I am getting “404 page not found”. Is there a way to tweak this to make it work ? or any other way to reach my goal?