1. The API and the dashboard #
What Traefik exposes.
Endpoints #
| Endpoint | Content |
|---|---|
/api/overview | Summary: number of routers, services, middlewares, errors and warnings |
/api/http/routers, /api/http/services, /api/http/middlewares | HTTP objects (also /api/tcp/… and /api/udp/…) |
/api/entrypoints | Entrypoints |
/api/rawdata | The whole merged dynamic configuration |
/api/version | Traefik version |
/dashboard/ | Web interface, built on the API |
2. Securing access #
Never left open.
Configuration #
# statique
api:
dashboard: true # et surtout pas insecure: true en production
# dynamique (fichier)
http:
routers:
tableau-de-bord:
rule: Host(`traefik.exemple.fr`)
entryPoints: [websecure]
service: api@internal
middlewares: [interne, sso]
tls: { certResolver: le }
middlewares:
interne:
ipAllowList: { sourceRange: ["10.0.0.0/8", "192.168.0.0/16"] }3. Using the API in scripts #
Checking after each deployment.
Examples #
API=https://traefik.exemple.fr/api
curl -s $API/overview | jq '.http' # totaux, avertissements, erreurs
curl -s $API/http/routers | jq -r '.[] | select(.status != "enabled") | "\(.name) \(.status) \(.error)"'
curl -s $API/http/services | jq -r '.[] | select(.serverStatus) | .name as $n | .serverStatus | to_entries[] | select(.value=="DOWN") | "\($n) \(.key) DOWN"'
curl -s $API/http/routers/app@docker | jq '{rule, service, middlewares, tls}'Good practice: Add a check for routers in error to your deployment pipeline: a typo in a label is detected immediately.
