Hi there,
I am relatively new to Docker, trying to set up Traefik v2 as a reverse proxy locally for a bunch of services on a home server before tying it to my public domain and configuring certificates, etc. Keeping it simple to start. I was having better luck with commands and labels than a config file, so trying to do everything within Docker Compose. When I set a router up to use the Host rule, like for the Traefik dashboard, I have no problem accessing the service (and even got the middleware to check that the connection is local, great.) When I try to use Path, however, I can't access it. I have confirmed that all containers are on the same Docker network, and when I open a shell inside the traefik container I can successfully curl for the connected container and port. But when I visit the path on the host, I get a 404. I went back a few versions just to make sure I wasn't stumbling into a recent breaking change that might not be well-documented. Didn't help. Been working on this for days. Docker Compose file below:
version: "3.8"
services:
traefik:
container_name: traefik
image: traefik:v2.1.2
restart: always
command:
- "--api.dashboard=true"
- "--log.level=INFO"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--log.filePath=/logs/traefik.log"
- "--log.format=json"
environment:
- TZ=${TZ}
ports:
- "80:80"
- "443:443"
# - "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
# - ${CONFIGDIR}/traefik/acme.json:/acme.json
- ${CONFIGDIR}/traefik/logs:/logs
networks:
- proxy
labels:
- traefik.enable=true
- docker.domain=doghouse.lan
- traefik.http.routers.api.service=api@internal
- traefik.http.routers.api.entrypoints=web
- traefik.http.routers.api.rule=Host(`machine.lan`)
- traefik.http.routers.api.middlewares=lan
- traefik.http.middlewares.lan.ipwhitelist.sourcerange=192.168.1.0/24
portainer:
container_name: portainer
image: portainer/portainer-ce
restart: always
# ports:
# - "8000:8000"
# - "9000:9000"
networks:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
- /srv/docker/shared:/shared
environment:
- TZ=${TZ}
labels:
- traefik.enable=true
- traefik.http.services.portainer.loadbalancer.server.port=9000
- traefik.http.routers.portainer.service=portainer
- traefik.http.routers.portainer.rule=Path(`/portainer`)
- traefik.http.routers.portainer.entrypoints=web
# VOLUMES
volumes:
portainer_data:
# NETWORKS
networks:
proxy:
driver: bridge
For the portainer container, I've tried both:
- traefik.http.routers.portainer.rule=Path(`/portainer`)
- traefik.http.routers.portainer.rule=Host(`machine.lan`) && Path(`/portainer`)
...and neither get me to the service via http://machine.lan/portainer
via the basic web entrypoint. I would honestly prefer subdomains, but I haven't dug into how I could resolve them with the local domain provided by my router.
Dashboard screenshots attached for reference.
Any help or guidance would be hugely appreciated... Thank you!