traefik/docs/content/operations/api.md
2019-09-02 03:26:04 -07:00

4.6 KiB

API

!!! important In the RC version, you can't configure middlewares (basic authentication or white listing) anymore, but as security is important, this will change before the GA version.

Traefik exposes a number of information through an API handler, such as the configuration of all routers, services, middlewares, etc.

As with all features of Traefik, this handler can be enabled with the static configuration.

Security

Enabling the API in production is not recommended, because it will expose all configuration elements, including sensitive data.

In production, it should be at least secured by authentication and authorizations.

A good sane default (non exhaustive) set of recommendations would be to apply the following protection mechanisms:

  • At the transport level:
    NOT publicly exposing the API's port, keeping it restricted to internal networks (as in the principle of least privilege, applied to networks).

!!! important In the beta version, you can't configure middlewares (basic authentication or white listing) anymore, but as security is important, this will change before the RC version.

Configuration

To enable the API handler:

[api]
api: {}
--api=true

dashboard

Optional, Default=true

Enable the dashboard. More about the dashboard features here.

[api]
  dashboard = true
api:
  dashboard: true
--api.dashboard=true

debug

Optional, Default=false

Enable additional endpoints for debugging and profiling, served under /debug/.

[api]
  debug = true
api:
  debug: true
--api.debug=true

Endpoints

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

Path Description
/api/http/routers Lists all the HTTP routers information.
/api/http/routers/{name} Returns the information of the HTTP router specified by name.
/api/http/services Lists all the HTTP services information.
/api/http/services/{name} Returns the information of the HTTP service specified by name.
/api/http/middlewares Lists all the HTTP middlewares information.
/api/http/middlewares/{name} Returns the information of the HTTP middleware specified by name.
/api/tcp/routers Lists all the TCP routers information.
/api/tcp/routers/{name} Returns the information of the TCP router specified by name.
/api/tcp/services Lists all the TCP services information.
/api/tcp/services/{name} Returns the information of the TCP service specified by name.
/api/entrypoints Lists all the entry points information.
/api/entrypoints/{name} Returns the information of the entry point specified by name.
/api/version Returns information about Traefik version.
/debug/vars See the expvar Go documentation.
/debug/pprof/ See the pprof Index Go documentation.
/debug/pprof/cmdline See the pprof Cmdline Go documentation.
/debug/pprof/profile See the pprof Profile Go documentation.
/debug/pprof/symbol See the pprof Symbol Go documentation.
/debug/pprof/trace See the pprof Trace Go documentation.