Web Provider

DEPRECATED

The web provider is deprecated, please use the api, the ping, the metrics and the rest provider.

Traefik can be configured:

  • using a RESTful api.
  • to use a monitoring system (like Prometheus, DataDog or StatD, …).
  • to expose a Web Dashboard.

Configuration

  1. # Enable Web Provider.
  2. [web]
  3. # Web administration port.
  4. #
  5. # Required
  6. # Default: ":8080"
  7. #
  8. address = ":8080"
  9. # SSL certificate and key used.
  10. #
  11. # Optional
  12. #
  13. # certFile = "traefik.crt"
  14. # keyFile = "traefik.key"
  15. # Set REST API to read-only mode.
  16. #
  17. # Optional
  18. # Default: false
  19. #
  20. readOnly = true
  21. # Set the root path for webui and API
  22. #
  23. # Deprecated
  24. # Optional
  25. #
  26. # path = "/mypath"
  27. #

Web UI

Web UI Providers

Web UI Health

Authentication

Note

The /ping path of the API is excluded from authentication (since 1.4).

Basic Authentication

Passwords can be encoded in MD5, SHA1 and BCrypt: you can use htpasswd to generate those ones.

Users can be specified directly in the TOML file, or indirectly by referencing an external file; if both are provided, the two are merged, with external file contents having precedence.

  1. [web]
  2. # ...
  3. # To enable basic auth on the webui with 2 user/pass: test:test and test2:test2
  4. [web.auth.basic]
  5. users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
  6. usersFile = "/path/to/.htpasswd"
  7. # ...

Digest Authentication

You can use htdigest to generate those ones.

Users can be specified directly in the TOML file, or indirectly by referencing an external file; if both are provided, the two are merged, with external file contents having precedence

  1. [web]
  2. # ...
  3. # To enable digest auth on the webui with 2 user/realm/pass: test:traefik:test and test2:traefik:test2
  4. [web.auth.digest]
  5. users = ["test:traefik:a2688e031edb4be6a3797f3882655c05", "test2:traefik:518845800f9e2bfb1f1f740ec24f074e"]
  6. usersFile = "/path/to/.htdigest"
  7. # ...

Metrics

You can enable Traefik to export internal metrics to different monitoring systems.

Prometheus

  1. [web]
  2. # ...
  3. # To enable Traefik to export internal metrics to Prometheus
  4. [web.metrics.prometheus]
  5. # Buckets for latency metrics
  6. #
  7. # Optional
  8. # Default: [0.1, 0.3, 1.2, 5]
  9. buckets=[0.1,0.3,1.2,5.0]
  10. # ...

DataDog

  1. [web]
  2. # ...
  3. # DataDog metrics exporter type
  4. [web.metrics.datadog]
  5. # DataDog's address.
  6. #
  7. # Required
  8. # Default: "localhost:8125"
  9. #
  10. address = "localhost:8125"
  11. # DataDog push interval
  12. #
  13. # Optional
  14. # Default: "10s"
  15. #
  16. pushinterval = "10s"
  17. # ...

StatsD

  1. [web]
  2. # ...
  3. # StatsD metrics exporter type
  4. [web.metrics.statsd]
  5. # StatD's address.
  6. #
  7. # Required
  8. # Default: "localhost:8125"
  9. #
  10. address = "localhost:8125"
  11. # StatD push interval
  12. #
  13. # Optional
  14. # Default: "10s"
  15. #
  16. pushinterval = "10s"
  17. # ...

InfluxDB

  1. [web]
  2. # ...
  3. # InfluxDB metrics exporter type
  4. [web.metrics.influxdb]
  5. # InfluxDB's address.
  6. #
  7. # Required
  8. # Default: "localhost:8089"
  9. #
  10. address = "localhost:8089"
  11. # InfluxDB's address protocol (udp or http)
  12. #
  13. # Required
  14. # Default: "udp"
  15. #
  16. protocol = "udp"
  17. # InfluxDB push interval
  18. #
  19. # Optional
  20. # Default: "10s"
  21. #
  22. pushinterval = "10s"
  23. # InfluxDB database used when protocol is http
  24. #
  25. # Optional
  26. # Default: ""
  27. #
  28. database = ""
  29. # InfluxDB retention policy used when protocol is http
  30. #
  31. # Optional
  32. # Default: ""
  33. #
  34. retentionpolicy = ""
  35. # ...

Statistics

  1. [web]
  2. # ...
  3. # Enable more detailed statistics.
  4. [web.statistics]
  5. # Number of recent errors logged.
  6. #
  7. # Default: 10
  8. #
  9. recentErrors = 10
  10. # ...

API

Path Method Description
/ GET Provides a simple HTML frontend of Traefik
/ping GET, HEAD A simple endpoint to check for Traefik process liveness. Return a code 200 with the content: OK
/health GET JSON health metrics
/api GET Configuration for all providers
/api/providers GET Providers
/api/providers/{provider} GET, PUT Get or update provider
/api/providers/{provider}/backends GET List backends
/api/providers/{provider}/backends/{backend} GET Get backend
/api/providers/{provider}/backends/{backend}/servers GET List servers in backend
/api/providers/{provider}/backends/{backend}/servers/{server} GET Get a server in a backend
/api/providers/{provider}/frontends GET List frontends
/api/providers/{provider}/frontends/{frontend} GET Get a frontend
/api/providers/{provider}/frontends/{frontend}/routes GET List routes in a frontend
/api/providers/{provider}/frontends/{frontend}/routes/{route} GET Get a route in a frontend
/metrics GET Export internal metrics

Example

Ping

  1. curl -sv "http://localhost:8080/ping"
  1. * Trying ::1...
  2. * Connected to localhost (::1) port 8080 (\#0)
  3. > GET /ping HTTP/1.1
  4. > Host: localhost:8080
  5. > User-Agent: curl/7.43.0
  6. > Accept: */*
  7. >
  8. < HTTP/1.1 200 OK
  9. < Date: Thu, 25 Aug 2016 01:35:36 GMT
  10. < Content-Length: 2
  11. < Content-Type: text/plain; charset=utf-8
  12. <
  13. * Connection \#0 to host localhost left intact
  14. OK

Health

  1. curl -s "http://localhost:8080/health" | jq .
  1. {
  2. // Traefik PID
  3. "pid": 2458,
  4. // Traefik server uptime (formated time)
  5. "uptime": "39m6.885931127s",
  6. // Traefik server uptime in seconds
  7. "uptime_sec": 2346.885931127,
  8. // current server date
  9. "time": "2015-10-07 18:32:24.362238909 +0200 CEST",
  10. // current server date in seconds
  11. "unixtime": 1444235544,
  12. // count HTTP response status code in realtime
  13. "status_code_count": {
  14. "502": 1
  15. },
  16. // count HTTP response status code since Traefik started
  17. "total_status_code_count": {
  18. "200": 7,
  19. "404": 21,
  20. "502": 13
  21. },
  22. // count HTTP response
  23. "count": 1,
  24. // count HTTP response
  25. "total_count": 41,
  26. // sum of all response time (formated time)
  27. "total_response_time": "35.456865605s",
  28. // sum of all response time in seconds
  29. "total_response_time_sec": 35.456865605,
  30. // average response time (formated time)
  31. "average_response_time": "864.8016ms",
  32. // average response time in seconds
  33. "average_response_time_sec": 0.8648016000000001,
  34. // request statistics [requires --web.statistics to be set]
  35. // ten most recent requests with 4xx and 5xx status codes
  36. "recent_errors": [
  37. {
  38. // status code
  39. "status_code": 500,
  40. // description of status code
  41. "status": "Internal Server Error",
  42. // request HTTP method
  43. "method": "GET",
  44. // request host name
  45. "host": "localhost",
  46. // request path
  47. "path": "/path",
  48. // RFC 3339 formatted date/time
  49. "time": "2016-10-21T16:59:15.418495872-07:00"
  50. }
  51. ]
  52. }

Provider configurations

  1. curl -s "http://localhost:8080/api" | jq .
  1. {
  2. "file": {
  3. "frontends": {
  4. "frontend2": {
  5. "routes": {
  6. "test_2": {
  7. "rule": "Path:/test"
  8. }
  9. },
  10. "backend": "backend1"
  11. },
  12. "frontend1": {
  13. "routes": {
  14. "test_1": {
  15. "rule": "Host:test.localhost"
  16. }
  17. },
  18. "backend": "backend2"
  19. }
  20. },
  21. "backends": {
  22. "backend2": {
  23. "loadBalancer": {
  24. "method": "drr"
  25. },
  26. "servers": {
  27. "server2": {
  28. "weight": 2,
  29. "URL": "http://172.17.0.5:80"
  30. },
  31. "server1": {
  32. "weight": 1,
  33. "url": "http://172.17.0.4:80"
  34. }
  35. }
  36. },
  37. "backend1": {
  38. "loadBalancer": {
  39. "method": "wrr"
  40. },
  41. "circuitBreaker": {
  42. "expression": "NetworkErrorRatio() > 0.5"
  43. },
  44. "servers": {
  45. "server2": {
  46. "weight": 1,
  47. "url": "http://172.17.0.3:80"
  48. },
  49. "server1": {
  50. "weight": 10,
  51. "url": "http://172.17.0.2:80"
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }

Deprecation compatibility

Address

As the web provider is deprecated, you can handle the Address option like this:

  1. defaultEntryPoints = ["http"]
  2. [entryPoints]
  3. [entryPoints.http]
  4. address = ":80"
  5. [entryPoints.foo]
  6. address = ":8082"
  7. [entryPoints.bar]
  8. address = ":8083"
  9. [ping]
  10. entryPoint = "foo"
  11. [api]
  12. entryPoint = "bar"

In the above example, you would access a regular path, administration panel, and health-check as follows:

In the above example, it is very important to create a named dedicated entry point, and do not include it in defaultEntryPoints. Otherwise, you are likely to expose all services via that entry point.

Path

As the web provider is deprecated, you can handle the Path option like this:

  1. defaultEntryPoints = ["http"]
  2. [entryPoints]
  3. [entryPoints.http]
  4. address = ":80"
  5. [entryPoints.foo]
  6. address = ":8080"
  7. [entryPoints.bar]
  8. address = ":8081"
  9. # Activate API and Dashboard
  10. [api]
  11. entryPoint = "bar"
  12. dashboard = true
  13. [file]
  14. [backends]
  15. [backends.backend1]
  16. [backends.backend1.servers.server1]
  17. url = "http://127.0.0.1:8081"
  18. [frontends]
  19. [frontends.frontend1]
  20. entryPoints = ["foo"]
  21. backend = "backend1"
  22. [frontends.frontend1.routes.test_1]
  23. rule = "PathPrefixStrip:/yourprefix;PathPrefix:/yourprefix"

Authentication

As the web provider is deprecated, you can handle the auth option like this:

  1. defaultEntryPoints = ["http"]
  2. [entryPoints]
  3. [entryPoints.http]
  4. address = ":80"
  5. [entryPoints.foo]
  6. address=":8080"
  7. [entryPoints.foo.auth]
  8. [entryPoints.foo.auth.basic]
  9. users = [
  10. "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
  11. "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
  12. ]
  13. [api]
  14. entrypoint="foo"

For more information, see entry points .