API & Dashboard

The dashboard is the central place that shows you the current active routes handled by Traefik.

Dashboard - Providers
The dashboard in action

Configuration Example

Enable the dashboard:

File(YAML)

  1. api: {}

File(TOML)

  1. [api]

CLI

  1. --api=true

Expose the dashboard:

Kubernetes CRD

  1. apiVersion: traefik.io/v1alpha1
  2. kind: IngressRoute
  3. metadata:
  4. name: traefik-dashboard
  5. spec:
  6. routes:
  7. - match: Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
  8. kind: Rule
  9. services:
  10. - name: api@internal
  11. kind: TraefikService
  12. middlewares:
  13. - name: auth
  14. ---
  15. apiVersion: traefik.io/v1alpha1
  16. kind: Middleware
  17. metadata:
  18. name: auth
  19. spec:
  20. basicAuth:
  21. secret: secretName # Kubernetes secret named "secretName"

Helm Chart Values (values.yaml)

  1. # Create an IngressRoute for the dashboard
  2. ingressRoute:
  3. dashboard:
  4. enabled: true
  5. # Custom match rule with host domain
  6. matchRule: Host(`traefik.example.com`)
  7. entryPoints: ["websecure"]
  8. # Add custom middlewares : authentication and redirection
  9. middlewares:
  10. - name: traefik-dashboard-auth
  11. # Create the custom middlewares used by the IngressRoute dashboard (can also be created in another way).
  12. # /!\ Yes, you need to replace "changeme" password with a better one. /!\
  13. extraObjects:
  14. - apiVersion: v1
  15. kind: Secret
  16. metadata:
  17. name: traefik-dashboard-auth-secret
  18. type: kubernetes.io/basic-auth
  19. stringData:
  20. username: admin
  21. password: changeme
  22. - apiVersion: traefik.io/v1alpha1
  23. kind: Middleware
  24. metadata:
  25. name: traefik-dashboard-auth
  26. spec:
  27. basicAuth:
  28. secret: traefik-dashboard-auth-secret

Docker

  1. # Dynamic Configuration
  2. labels:
  3. - "traefik.http.routers.dashboard.rule=Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  4. - "traefik.http.routers.dashboard.service=api@internal"
  5. - "traefik.http.routers.dashboard.middlewares=auth"
  6. - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"

Swarm

  1. # Dynamic Configuration
  2. deploy:
  3. labels:
  4. - "traefik.http.routers.dashboard.rule=Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  5. - "traefik.http.routers.dashboard.service=api@internal"
  6. - "traefik.http.routers.dashboard.middlewares=auth"
  7. - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
  8. # Dummy service for Swarm port detection. The port can be any valid integer value.
  9. - "traefik.http.services.dummy-svc.loadbalancer.server.port=9999"

Consul Catalog

  1. # Dynamic Configuration
  2. - "traefik.http.routers.dashboard.rule=Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  3. - "traefik.http.routers.dashboard.service=api@internal"
  4. - "traefik.http.routers.dashboard.middlewares=auth"
  5. - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"

File (YAML)

  1. # Dynamic Configuration
  2. http:
  3. routers:
  4. dashboard:
  5. rule: Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
  6. service: api@internal
  7. middlewares:
  8. - auth
  9. middlewares:
  10. auth:
  11. basicAuth:
  12. users:
  13. - "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"
  14. - "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"

File (TOML)

  1. # Dynamic Configuration
  2. [http.routers.my-api]
  3. rule = "Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  4. service = "api@internal"
  5. middlewares = ["auth"]
  6. [http.middlewares.auth.basicAuth]
  7. users = [
  8. "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
  9. "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
  10. ]

Configuration Options

The API and the dashboard can be configured:

  • In the Helm Chart: You can find the options to customize the Traefik installation enabing the dashboard here.
  • In the Traefik Static Configuration as described below.
FieldDescriptionDefaultRequired
apiEnable api/dashboard. When set to true, its sub option api.dashboard is also set to true.falseNo
api.dashboardEnable dashboard.falseNo
api.debugEnable additional endpoints for debugging and profiling.falseNo
api.disabledashboardadDisable the advertisement from the dashboard.falseNo
api.insecureEnable the API and the dashboard on the entryPoint named traefik.falseNo

Endpoints

All the following endpoints must be accessed with a GET HTTP request.

PathDescription
/api/http/routersLists all the HTTP routers information.
/api/http/routers/{name}Returns the information of the HTTP router specified by name.
/api/http/servicesLists all the HTTP services information.
/api/http/services/{name}Returns the information of the HTTP service specified by name.
/api/http/middlewaresLists all the HTTP middlewares information.
/api/http/middlewares/{name}Returns the information of the HTTP middleware specified by name.
/api/tcp/routersLists all the TCP routers information.
/api/tcp/routers/{name}Returns the information of the TCP router specified by name.
/api/tcp/servicesLists all the TCP services information.
/api/tcp/services/{name}Returns the information of the TCP service specified by name.
/api/tcp/middlewaresLists all the TCP middlewares information.
/api/tcp/middlewares/{name}Returns the information of the TCP middleware specified by name.
/api/udp/routersLists all the UDP routers information.
/api/udp/routers/{name}Returns the information of the UDP router specified by name.
/api/udp/servicesLists all the UDP services information.
/api/udp/services/{name}Returns the information of the UDP service specified by name.
/api/entrypointsLists all the entry points information.
/api/entrypoints/{name}Returns the information of the entry point specified by name.
/api/overviewReturns statistic information about HTTP, TCP and about enabled features and providers.
/api/rawdataReturns information about dynamic configurations, errors, status and dependency relations.
/api/versionReturns information about Traefik version.
/debug/varsSee the expvar Go documentation.
/debug/pprof/See the pprof Index Go documentation.
/debug/pprof/cmdlineSee the pprof Cmdline Go documentation.
/debug/pprof/profileSee the pprof Profile Go documentation.
/debug/pprof/symbolSee the pprof Symbol Go documentation.
/debug/pprof/traceSee the pprof Trace Go documentation.

Dashboard

The dashboard is available at the same location as the API, but by default on the path /dashboard/.

Note

  • The trailing slash / in /dashboard/ is mandatory. This limitation can be mitigated using the the RedirectRegex Middleware.
  • There is also a redirect from the path / to /dashboard/, but you should not rely on this behavior, as it is subject to change and may complicate routing rules.

To securely access the dashboard, you need to define a routing configuration within Traefik. This involves setting up a router attached to the service api@internal, which allows you to:

Dashboard Router Rule

To ensure proper access to the dashboard, the router rule you define must match requests intended for the /api and /dashboard paths. We recommend using either a Host-based rule to match all requests on the desired domain or explicitly defining a rule that includes both path prefixes. Here are some examples:

Host Rule

  1. # The dashboard can be accessed on http://traefik.example.com/dashboard/
  2. rule = "Host(`traefik.example.com`)"

Path Prefix Rule

  1. # The dashboard can be accessed on http://example.com/dashboard/ or http://traefik.example.com/dashboard/
  2. rule = "PathPrefix(`/api`) || PathPrefix(`/dashboard`)"

Combination of Rules

  1. # The dashboard can be accessed on http://traefik.example.com/dashboard/
  2. rule = "Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"

Using Traefik OSS in Production?

If you are using Traefik at work, consider adding enterprise-grade API gateway capabilities or commercial support for Traefik OSS.

Adding API Gateway capabilities to Traefik OSS is fast and seamless. There’s no rip and replace and all configurations remain intact. See it in action via this short video.