Hi,
In the screenshot above, portainer is stucked in this weird state without the /
. At the moment, I need to add it manually. Per example mydomain.club/portainer/
EDIT: it's not limited to portainer
As I'm migrating from V1 to V2, I can't find the right way to write the middleware(s) in Traefik V2 that will automatically add the missing /.
In V1 here is how it worked:
## Working configs from traefik:v1.7
## fixed https://github.com/containous/traefik/issues/563#issuecomment-421360934
- "traefik.frontend.redirect.regex=^(.*)/portainer$$"
- "traefik.frontend.redirect.replacement=$$1/portainer/"
- "traefik.frontend.rule=PathPrefix:/portainer;ReplacePathRegex: ^/portainer/(.*) /$$1"
In v2 without the redirectregex (working)
This works with portainer. But I will need to manually add a /
at the end.
version: "3.3"
services:
portainer:
image: portainer/portainer
...
labels:
#### core configs
- "traefik.enable=true"
- "traefik.http.routers.portainer.rule=Host(`mydomain.club`) && PathPrefix(`/portainer`)"
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
#### set TLS (https)
- "traefik.http.routers.portainer.entrypoints=websecure"
- "traefik.http.routers.portainer.tls=true"
- "traefik.http.routers.portainer.tls.certresolver=leresolver"
#### use these middlewares (rules like our-auth,our-retry,our-ratelimit are defined within traefik's labels)
- "traefik.http.routers.portainer.middlewares=our-auth,our-retry,our-ratelimit,our-header,portainer-strip"
#___ specific middleware rule for this service
- "traefik.http.middlewares.portainer-strip.stripprefix.prefixes=/portainer"
In v2 with redirectregex + replacepathregex
Not working yet ... draft in progress.
labels:
#### core configs
- "traefik.enable=true"
- "traefik.http.routers.portainer.rule=Host(`mydomain.club`) && PathPrefix(`/portainer`)"
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
#### set TLS (https)
- "traefik.http.routers.portainer.entrypoints=websecure"
- "traefik.http.routers.portainer.tls=true"
- "traefik.http.routers.portainer.tls.certresolver=leresolver"
#### use these middlewares (rules like our-auth,our-retry,our-ratelimit are defined within traefik's labels)
- "traefik.http.routers.portainer.middlewares=our-auth,our-retry,our-ratelimit,our-header,portainer-strip,portainer-trailingslash"
#___ specific middleware rule for this service
- "traefik.http.middlewares.portainer-strip.stripprefix.prefixes=/portainer"
#___ add missing '/' at the end i.e. mydomain.club/portainer/
- "traefik.http.middlewares.portainer-trailingslash.replacepathregex.regex=^/portainer(.*)"
- "traefik.http.middlewares.portainer-trailingslash.replacepathregex.replacement=/portainer/$$1"
Thanks in advance!