Rest Provider

Traefik can be configured:

  • using a RESTful api.

Configuration

  1. # Enable REST Provider.
  2. [rest]
  3. # Name of the related entry point
  4. #
  5. # Optional
  6. # Default: "traefik"
  7. #
  8. entryPoint = "traefik"

API

Path Method Description
/api/providers/web PUT update provider
/api/providers/rest PUT update provider

Warning

For compatibility reason, when you activate the rest provider, you can use web or rest as provider value.

  1. curl -XPUT -d @file "http://localhost:8080/api/providers/rest"

with @file:

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