Adding Traefik StripPrefix middleware to docker-compose labels results in 504 Adding Traefik StripPrefix middleware to docker-compose labels results in 504 nginx nginx

Adding Traefik StripPrefix middleware to docker-compose labels results in 504


There is an issue with prefix without ending with '/'. Test your config like this:

      - "traefik.http.routers.whoami.rule=Host(`localhost`) && (PathPrefix(`//whoami/`) || PathPrefix(`/portainer`))"      - "traefik.http.middlewares.strip-who.stripprefix.prefixes=/whoami"


I had a similar problem that was solved with the addition of

- "traefik.http.middlewares.strip-who.stripprefix.forceslash=true"

It makes sure the strip prefix doesn't also remove the forward slash.

You can read more about the forceslash documentation https://docs.traefik.io/middlewares/stripprefix/