404 when using PathPrefix with docker swarm

I'm running a docker swarm cluster with traefik on the manager node. I have an alias set up in /etc/hosts for the manager node as homelab. My swarm has an overlay network named traefik_internal.

I've got portainer set up in the swarm with these labels:

- "traefik.enable=true"
- "traefik.docker.network=traefik_internal"
- "traefik.http.routers.portainer.rule=PathPrefix(`/portainer`)"
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
- "traefik.http.routers.portainer.entrypoints=http"
- "traefik.http.middlewares.portainer.stripprefix.prefixes=/portainer"
- "traefik.http.middlewares.portainer.stripprefix.forceSlash=false"

When I navigate to http://homelab/portainer I get the normal traefik 404 page not found string. I'm having the same problem trying to expose the traefik dashboard using these labels:

- "traefik.enable=true"
- "traefik.docker.network=traefik_internal"
- "traefik.http.routers.traefik.rule=PathPrefix(`/traefik`)"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.middlewares.traefik.stripprefix.prefixes=/traefik"
- "traefik.http.middlewares.traefik.stripprefix.forceSlash=false"

When I run docker network inspect on the traefik_internal network I can see my container and its IP:

"5f80181c85c908ab118f06999e2d755c62b1aa586a3e49225308d17fc064eb4d": {
"Name": "portainer_portainer.1.sdyfy5ojyiiaalz5858e6gy71",
"EndpointID": "926f1c9230f3d0818c6c9374c3cbda146663edcf2d98f89185ae1d7d3c000f38",
"MacAddress": "02:42:0a:00:01:3a",
"IPv4Address": "",
"IPv6Address": ""

And in the traefik logs when I go to that URL I can see it's trying to forward to the correct IP address:

Forwarding this request to URL" ForwardURL="[]("

But in chrome I just see 404 page not found. Am I missing some configuration or doing anything incorrectly?

Realised I wasn't actually adding the middleware to the router. It works fine when I do that!

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