2018-05-16 17:48:03 +00:00
|
|
|
# Rest Provider
|
2017-11-09 15:12:04 +00:00
|
|
|
|
2018-10-17 14:24:04 +00:00
|
|
|
Traefik can be configured:
|
2017-11-09 15:12:04 +00:00
|
|
|
|
|
|
|
- using a RESTful api.
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
```toml
|
2018-05-16 17:48:03 +00:00
|
|
|
# Enable REST Provider.
|
2017-11-09 15:12:04 +00:00
|
|
|
[rest]
|
|
|
|
# Name of the related entry point
|
|
|
|
#
|
|
|
|
# Optional
|
|
|
|
# Default: "traefik"
|
|
|
|
#
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
```shell
|
2018-03-01 07:42:03 +00:00
|
|
|
curl -XPUT @file "http://localhost:8080/api/providers/rest"
|
2017-11-09 15:12:04 +00:00
|
|
|
```
|
2018-03-01 07:42:03 +00:00
|
|
|
|
|
|
|
with `@file`:
|
2017-11-09 15:12:04 +00:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"frontends": {
|
|
|
|
"frontend2": {
|
|
|
|
"routes": {
|
|
|
|
"test_2": {
|
|
|
|
"rule": "Path:/test"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"backend": "backend1"
|
|
|
|
},
|
|
|
|
"frontend1": {
|
|
|
|
"routes": {
|
|
|
|
"test_1": {
|
|
|
|
"rule": "Host:test.localhost"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"backend": "backend2"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"backends": {
|
|
|
|
"backend2": {
|
|
|
|
"loadBalancer": {
|
|
|
|
"method": "drr"
|
|
|
|
},
|
|
|
|
"servers": {
|
|
|
|
"server2": {
|
|
|
|
"weight": 2,
|
|
|
|
"URL": "http://172.17.0.5:80"
|
|
|
|
},
|
|
|
|
"server1": {
|
|
|
|
"weight": 1,
|
|
|
|
"url": "http://172.17.0.4:80"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"backend1": {
|
|
|
|
"loadBalancer": {
|
|
|
|
"method": "wrr"
|
|
|
|
},
|
|
|
|
"circuitBreaker": {
|
|
|
|
"expression": "NetworkErrorRatio() > 0.5"
|
|
|
|
},
|
|
|
|
"servers": {
|
|
|
|
"server2": {
|
|
|
|
"weight": 1,
|
|
|
|
"url": "http://172.17.0.3:80"
|
|
|
|
},
|
|
|
|
"server1": {
|
|
|
|
"weight": 10,
|
|
|
|
"url": "http://172.17.0.2:80"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-01 07:42:03 +00:00
|
|
|
```
|