All subdirectories return 404

Hello @transistor,

Thanks for your interest in Traefik!

As the forwarded request contains the /portainer path a 404 Not Found error is returned by Portainer because it does not exist.

To remove the /portainer path from the forwarded request you can use the strip prefix middleware. The following labels have to be added to the portainer container:

- "traefik.http.routers.portainer-secure.middlewares=portainer-stripprefix"
- "traefik.http.middlewares.portainer-stripprefix.stripprefix.prefixes=/portainer"

With those labels, the 404 error is fixed but the portainer UI is not loading properly.

That's because the UI requests don't contain the portainer path (which is required to match the router rule). It seems that it's currently not possible to configure portainer to add this prefix: [FEAT] Add path prefix to web UI · Issue #3901 · portainer/portainer · GitHub

IMO the only solution is to use a dedicated domain in the router rule.