Skip to content

Instantly share code, notes, and snippets.

@grofit
Created May 23, 2020 19:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grofit/34c68dfa836eb351815edede5fc71f2f to your computer and use it in GitHub Desktop.
Save grofit/34c68dfa836eb351815edede5fc71f2f to your computer and use it in GitHub Desktop.
Setting up Traefik 2 dashboard with basic auth, this is the same as my basic traefik 2 setup but with user auth from a file, you can see the original one here https://gist.github.com/grofit/e9a94ca02ba31ed1db9f88104f81c502
version: "3.7"
services:
traefik:
image: "traefik:v2.2"
container_name: "traefik"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/traefik.yml:/traefik.yml:ro"
- "/user-credentials:/user-credentials:ro" # Added some user credentials
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.service=api@internal"
- "traefik.http.routers.api.entrypoints=api"
- "traefik.http.routers.api.rule=Host(`localhost`)"
- "traefik.http.routers.api.middlewares=auth" # Tell our route to use a middleware named `auth`
- "traefik.http.middlewares.auth.basicauth.usersfile=/user-credentials" # Setup the `auth` middleware to be basicauth that takes a file for users
log:
level: INFO
api:
dashboard: true
entryPoints:
http:
address: ":80"
api:
address: ":8080"
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
watch: true
admin:$2y$10$uFGdAIp/0EEUegJjqF55AOc79.8Rv2TSnsO2BLN7uUm0g.BCx4JsW
someone:$Ay$10$uFGdAIp/0EEUegJjqF55AOc79.8Rv2TSnsO2BLN7uUm0g.BFx4JsW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment