Problem:
I've tried to enable basic auth on traefik dashboard. Traefik dashboard isn't protected by basic auth when I visit traefik.mydomain.test
I get page not found 404 page.
As the directive exposedByDefault is set to false in your static Traefik configuration,
then you must add the label traefik.enable=true if you want Traefik to pick the container
I am also facing the same issue, I am not able to get the api and dashboard working following the steps in the documentation. Here is my docker-compose file. Any help is very much appreciated
version: "3.3"
services:
whoami:
image: "containous/whoami"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`test.com`)"
- "traefik.http.routers.whoami.entrypoints=web"
- "traefik.http.services.whoami.loadbalancer.server.port=80"
reverse-proxy:
image: traefik:v2.0 # The official Traefik docker image
command:
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--log.level=DEBUG"
- "--accesslog=true"
- "--api=true"
- "--api.dashboard=true"
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
labels:
- "traefik.http.routers.proxy.rule=Host(`traefik.test.com`)"
- "traefik.http.routers.proxy.service=api@internal"
- "traefik.http.routers.proxy.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
I am able to access the whoami service using test.com however i am not able to access the dashboard or api. I have checked the proxy logs, looks like the labels configured for proxy are not picked by traefik. Here is the corresponding log
Hi @rnmkr, you have to use http://traefik.mydomain.test:8080 in your case:
Port 8080 because your published the 8080 to the 80 of traefik container in Docker:
ports:
- "0.0.0.0:8080:80"
If you want to reach the standard port, you must adapt this NAT rule: this is outside Traefik
HTTP protocol (instead of HTTPS), because you did not enable TLS on the router. Here are the labels if you want to have https enabled + http to https redirection for the dashboard. Please note that certificate will be auto-signed and will change on each traefik restart or new router: you'll have to provide your own certificate manually or use let's encrypt (ref. https://docs.traefik.io/v2.1/https/tls/#certificates-definition).