Traefik dashboard on another port and with authentication
Here is an example for Traefik dashbord on port 9090 and with basic auth middleware.
To generate password:
echo $(htpasswd -nb user password) | sed -e s/\\$/\\$\\$/g
For services routers it’s important to set entryPoints with correct port: "traefik.http.routers.ui.entryPoints=web"
.
version: '3.3'
services:
ui:
image: "ui:v1.0.0"
restart: always
labels:
- "traefik.enable=true"
- "traefik.http.routers.ui.entryPoints=web"
- "traefik.http.routers.ui.rule=Host(`${HOST_NAME}`)"
- "traefik.http.services.ui.loadbalancer.server.port=8080"
- "traefik.http.services.ui.loadbalancer.server.scheme=http"
traefik:
image: "traefik:v2.1.7"
restart: always
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.dashboard.address=:8080"
- "--api=true"
- "--api.dashboard=true"
- "--accesslog=true"
ports:
- "80:80"
- "9090:8080"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.entryPoints=dashboard"
- "traefik.http.routers.dashboard.rule=Host(`${HOST_NAME}`)"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.middlewares=dashboard-auth@docker"
- "traefik.http.middlewares.dashboard-auth.basicauth.users=user:$$apr1$$31lOQwG4$$VD15Ln4o5f5GgixYie9tW0"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"