Currently I\'m trying set up a loadbalancer/reverse proxy with Traefik for some docker containers. I\'m having trouble with configuring Treafik to make my apps available usi
for future googler
The reason it doesn't work without slash is an existing issue
https://github.com/containous/traefik/issues/563
For v2 docker label
- "traefik.http.routers.portainer-secure.rule=Host(`your-domain.com`) && PathPrefix(`/portainer`)"
- "traefik.http.routers.portainer-secure.middlewares=portainer-redirectregex, portainer-replacepathregex"
- "traefik.http.middlewares.portainer-replacepathregex.replacepathregex.regex=^/portainer/(.*)"
- "traefik.http.middlewares.portainer-replacepathregex.replacepathregex.replacement=/$$1"
- "traefik.http.middlewares.portainer-redirectregex.redirectregex.regex=^(.*)/portainer$$"
- "traefik.http.middlewares.portainer-redirectregex.redirectregex.replacement=$$1/portainer/"
This morning I found the solution. The correct approach in cases like these should be to use the PathPrefixStrip rule. However, as mentioned here, putting a /
at the end of the rule will break the setup. I created a working configuration by removing /
at the end of the PathPrefixStrip: /portainer4/
rule. So this docker-compose configuration worked for me:
version: '2'
services:
traefik:
container_name: traefik2
image: traefik
command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
ports:
- "80:80"
- "8081:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /dev/null:/traefik.toml
labels:
- "traefik.enable=false"
portainer:
image: portainer/portainer
labels:
- "traefik.backend=portainer"
- "traefik.frontend.rule=PathPrefixStrip: /portainer"
Now when I navigate to <myIP>/portainer/
I see the portainer page. I do, however, still get the white page as mentioned earlier when I navigate to <myIP>/portainer
.