2018-05-16 17:48:03 +00:00
# Web Provider
2017-08-25 19:32:33 +00:00
2017-11-09 15:12:04 +00:00
!!! danger "DEPRECATED"
The web provider is deprecated, please use the [api ](/configuration/api.md ), the [ping ](/configuration/ping.md ), the [metrics ](/configuration/metrics ) and the [rest ](/configuration/backends/rest.md ) provider.
2018-10-17 14:24:04 +00:00
Traefik can be configured:
2017-08-26 10:12:44 +00:00
- using a RESTful api.
2017-09-11 17:10:04 +00:00
- to use a monitoring system (like Prometheus, DataDog or StatD, ...).
2017-08-26 10:12:44 +00:00
- to expose a Web Dashboard.
2017-08-25 19:32:33 +00:00
## Configuration
```toml
2018-05-16 17:48:03 +00:00
# Enable Web Provider.
2017-08-25 19:32:33 +00:00
[web]
2017-09-11 17:10:04 +00:00
# Web administration port.
2017-08-25 19:32:33 +00:00
#
2017-08-26 10:12:44 +00:00
# Required
2017-09-15 07:18:03 +00:00
# Default: ":8080"
2017-08-25 19:32:33 +00:00
#
2017-08-26 10:12:44 +00:00
address = ":8080"
2017-09-11 17:10:04 +00:00
# SSL certificate and key used.
2017-08-25 19:32:33 +00:00
#
# Optional
#
2017-09-11 17:10:04 +00:00
# certFile = "traefik.crt"
# keyFile = "traefik.key"
2017-08-26 10:12:44 +00:00
2017-09-11 17:10:04 +00:00
# Set REST API to read-only mode.
2017-08-25 19:32:33 +00:00
#
# Optional
2017-10-02 08:32:02 +00:00
# Default: false
#
readOnly = true
2018-01-11 08:46:03 +00:00
# Set the root path for webui and API
#
# Deprecated
# Optional
#
# path = "/mypath"
#
2017-08-25 19:32:33 +00:00
```
## Web UI
2017-08-26 10:12:44 +00:00
2017-08-25 19:32:33 +00:00
![Web UI Providers ](/img/web.frontend.png )
![Web UI Health ](/img/traefik-health.png )
2017-09-05 13:58:03 +00:00
### Authentication
2017-09-11 17:10:04 +00:00
!!! note
2018-02-16 09:32:03 +00:00
The `/ping` path of the API is excluded from authentication (since 1.4).
2017-09-11 17:10:04 +00:00
2017-09-15 07:18:03 +00:00
#### Basic Authentication
2017-09-05 13:58:03 +00:00
Passwords can be encoded in MD5, SHA1 and BCrypt: you can use `htpasswd` to generate those ones.
2018-02-16 09:32:03 +00:00
Users can be specified directly in the TOML file, or indirectly by referencing an external file;
2017-09-05 13:58:03 +00:00
if both are provided, the two are merged, with external file contents having precedence.
```toml
2017-09-11 17:10:04 +00:00
[web]
# ...
2017-09-05 13:58:03 +00:00
# To enable basic auth on the webui with 2 user/pass: test:test and test2:test2
2017-09-11 17:10:04 +00:00
[web.auth.basic]
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
usersFile = "/path/to/.htpasswd"
# ...
2017-09-05 13:58:03 +00:00
```
2017-09-15 07:18:03 +00:00
#### Digest Authentication
2017-09-05 13:58:03 +00:00
You can use `htdigest` to generate those ones.
2018-02-16 09:32:03 +00:00
Users can be specified directly in the TOML file, or indirectly by referencing an external file;
2017-09-05 13:58:03 +00:00
if both are provided, the two are merged, with external file contents having precedence
```toml
2017-09-11 17:10:04 +00:00
[web]
# ...
2017-09-05 13:58:03 +00:00
# To enable digest auth on the webui with 2 user/realm/pass: test:traefik:test and test2:traefik:test2
2017-09-11 17:10:04 +00:00
[web.auth.digest]
2018-01-12 19:00:06 +00:00
users = ["test:traefik:a2688e031edb4be6a3797f3882655c05", "test2:traefik:518845800f9e2bfb1f1f740ec24f074e"]
2017-09-11 17:10:04 +00:00
usersFile = "/path/to/.htdigest"
# ...
2017-09-05 13:58:03 +00:00
```
2017-08-26 10:12:44 +00:00
## Metrics
2018-10-17 14:24:04 +00:00
You can enable Traefik to export internal metrics to different monitoring systems.
2017-08-26 10:12:44 +00:00
2017-09-15 07:18:03 +00:00
### Prometheus
2017-09-05 13:58:03 +00:00
2017-08-26 10:12:44 +00:00
```toml
2017-09-11 17:10:04 +00:00
[web]
# ...
2017-08-26 10:12:44 +00:00
# To enable Traefik to export internal metrics to Prometheus
2017-09-05 13:58:03 +00:00
[web.metrics.prometheus]
2017-09-15 07:18:03 +00:00
# Buckets for latency metrics
#
# Optional
# Default: [0.1, 0.3, 1.2, 5]
2017-09-11 17:10:04 +00:00
buckets=[0.1,0.3,1.2,5.0]
2018-02-16 09:32:03 +00:00
2017-09-11 17:10:04 +00:00
# ...
2017-09-05 13:58:03 +00:00
```
2017-08-26 10:12:44 +00:00
2017-09-15 07:18:03 +00:00
### DataDog
2017-09-05 13:58:03 +00:00
```toml
2017-09-11 17:10:04 +00:00
[web]
# ...
2017-09-07 10:02:03 +00:00
# DataDog metrics exporter type
2017-09-05 13:58:03 +00:00
[web.metrics.datadog]
2017-09-15 07:18:03 +00:00
# DataDog's address.
#
# Required
# Default: "localhost:8125"
#
2017-09-11 17:10:04 +00:00
address = "localhost:8125"
2017-09-15 07:18:03 +00:00
# DataDog push interval
#
# Optional
# Default: "10s"
#
2017-09-11 17:10:04 +00:00
pushinterval = "10s"
# ...
2017-09-05 13:58:03 +00:00
```
2017-08-26 10:12:44 +00:00
2017-09-15 07:18:03 +00:00
### StatsD
2017-09-05 13:58:03 +00:00
```toml
2017-09-11 17:10:04 +00:00
[web]
# ...
2017-08-26 10:12:44 +00:00
# StatsD metrics exporter type
2017-09-05 13:58:03 +00:00
[web.metrics.statsd]
2017-09-15 07:18:03 +00:00
# StatD's address.
#
# Required
# Default: "localhost:8125"
#
2017-09-11 17:10:04 +00:00
address = "localhost:8125"
2017-09-15 07:18:03 +00:00
# StatD push interval
#
# Optional
# Default: "10s"
#
2017-09-11 17:10:04 +00:00
pushinterval = "10s"
# ...
2017-08-26 10:12:44 +00:00
```
2017-11-08 14:14:03 +00:00
### InfluxDB
```toml
[web]
# ...
# InfluxDB metrics exporter type
[web.metrics.influxdb]
# InfluxDB's address.
#
# Required
# Default: "localhost:8089"
#
address = "localhost:8089"
2018-05-29 20:58:03 +00:00
# InfluxDB's address protocol (udp or http)
#
# Required
# Default: "udp"
#
protocol = "udp"
2017-11-08 14:14:03 +00:00
# InfluxDB push interval
#
# Optional
# Default: "10s"
#
pushinterval = "10s"
2018-05-29 20:58:03 +00:00
# InfluxDB database used when protocol is http
#
# Optional
# Default: ""
#
database = ""
# InfluxDB retention policy used when protocol is http
#
# Optional
# Default: ""
#
retentionpolicy = ""
2017-11-08 14:14:03 +00:00
# ...
```
2017-09-15 07:18:03 +00:00
## Statistics
```toml
[web]
# ...
# Enable more detailed statistics.
[web.statistics]
# Number of recent errors logged.
#
# Default: 10
#
recentErrors = 10
# ...
```
2017-08-25 19:32:33 +00:00
## API
| Path | Method | Description |
|-----------------------------------------------------------------|:-------------:|----------------------------------------------------------------------------------------------------|
2018-10-17 14:24:04 +00:00
| `/` | `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` |
2018-02-16 09:32:03 +00:00
| `/health` | `GET` | JSON health metrics |
2017-08-25 19:32:33 +00:00
| `/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
2017-08-26 10:12:44 +00:00
2017-08-25 19:32:33 +00:00
#### Ping
2017-08-26 10:12:44 +00:00
2017-08-25 19:32:33 +00:00
```shell
2017-09-15 07:18:03 +00:00
curl -sv "http://localhost:8080/ping"
2017-08-26 10:12:44 +00:00
```
```shell
2017-08-25 19:32:33 +00:00
* Trying ::1...
2018-02-16 09:32:03 +00:00
* Connected to localhost (::1) port 8080 (\#0)
2017-08-25 19:32:33 +00:00
> GET /ping HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP / 1 . 1 200 OK
< Date: Thu , 25 Aug 2016 01:35:36 GMT
< Content-Length: 2
< Content-Type: text / plain ; charset = utf-8
<
2018-02-16 09:32:03 +00:00
* Connection \#0 to host localhost left intact
2017-08-25 19:32:33 +00:00
OK
```
#### Health
2017-08-26 10:12:44 +00:00
2017-08-25 19:32:33 +00:00
```shell
2017-09-15 07:18:03 +00:00
curl -s "http://localhost:8080/health" | jq .
2017-08-26 10:12:44 +00:00
```
```json
2017-08-25 19:32:33 +00:00
{
2018-10-17 14:24:04 +00:00
// Traefik PID
2017-08-25 19:32:33 +00:00
"pid": 2458,
2018-10-17 14:24:04 +00:00
// Traefik server uptime (formated time)
2017-08-25 19:32:33 +00:00
"uptime": "39m6.885931127s",
2018-10-17 14:24:04 +00:00
// Traefik server uptime in seconds
2017-08-25 19:32:33 +00:00
"uptime_sec": 2346.885931127,
// current server date
"time": "2015-10-07 18:32:24.362238909 +0200 CEST",
// current server date in seconds
"unixtime": 1444235544,
// count HTTP response status code in realtime
"status_code_count": {
"502": 1
},
2018-10-17 14:24:04 +00:00
// count HTTP response status code since Traefik started
2017-08-25 19:32:33 +00:00
"total_status_code_count": {
"200": 7,
"404": 21,
"502": 13
},
// count HTTP response
"count": 1,
// count HTTP response
"total_count": 41,
// sum of all response time (formated time)
"total_response_time": "35.456865605s",
// sum of all response time in seconds
"total_response_time_sec": 35.456865605,
// average response time (formated time)
"average_response_time": "864.8016ms",
// average response time in seconds
"average_response_time_sec": 0.8648016000000001,
// request statistics [requires --web.statistics to be set]
// ten most recent requests with 4xx and 5xx status codes
"recent_errors": [
{
// status code
"status_code": 500,
// description of status code
"status": "Internal Server Error",
// request HTTP method
"method": "GET",
2018-02-16 09:32:03 +00:00
// request host name
2017-08-25 19:32:33 +00:00
"host": "localhost",
// request path
"path": "/path",
// RFC 3339 formatted date/time
"time": "2016-10-21T16:59:15.418495872-07:00"
}
]
}
```
#### Provider configurations
2017-08-26 10:12:44 +00:00
2017-08-25 19:32:33 +00:00
```shell
2017-09-15 07:18:03 +00:00
curl -s "http://localhost:8080/api" | jq .
2017-08-26 10:12:44 +00:00
```
```json
2017-08-25 19:32:33 +00:00
{
"file": {
"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-01-11 08:46:03 +00:00
2018-02-16 09:32:03 +00:00
### Deprecation compatibility
2018-03-01 07:42:03 +00:00
#### Address
As the web provider is deprecated, you can handle the `Address` option like this:
```toml
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.foo]
address = ":8082"
[entryPoints.bar]
address = ":8083"
[ping]
entryPoint = "foo"
[api]
entryPoint = "bar"
```
In the above example, you would access a regular path, administration panel, and health-check as follows:
* Regular path: `http://hostname:80/path`
* Admin Panel: `http://hostname:8083/`
* Ping URL: `http://hostname:8082/ping`
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.
2018-02-16 09:32:03 +00:00
#### Path
2018-01-11 08:46:03 +00:00
2018-02-16 09:32:03 +00:00
As the web provider is deprecated, you can handle the `Path` option like this:
2018-01-11 08:46:03 +00:00
```toml
2018-02-16 09:32:03 +00:00
defaultEntryPoints = ["http"]
2018-01-11 08:46:03 +00:00
2018-02-16 09:32:03 +00:00
[entryPoints]
[entryPoints.http]
address = ":80"
2018-01-11 08:46:03 +00:00
2018-03-01 07:42:03 +00:00
[entryPoints.foo]
2018-02-16 09:32:03 +00:00
address = ":8080"
2018-01-11 08:46:03 +00:00
2018-03-01 07:42:03 +00:00
[entryPoints.bar]
2018-02-16 09:32:03 +00:00
address = ":8081"
# Activate API and Dashboard
2018-01-11 08:46:03 +00:00
[api]
2018-03-01 07:42:03 +00:00
entryPoint = "bar"
dashboard = true
2018-01-11 08:46:03 +00:00
[file]
[backends]
[backends.backend1]
[backends.backend1.servers.server1]
url = "http://127.0.0.1:8081"
[frontends]
[frontends.frontend1]
2018-03-01 07:42:03 +00:00
entryPoints = ["foo"]
2018-01-11 08:46:03 +00:00
backend = "backend1"
[frontends.frontend1.routes.test_1]
rule = "PathPrefixStrip:/yourprefix;PathPrefix:/yourprefix"
2018-02-16 09:32:03 +00:00
```
#### Authentication
As the web provider is deprecated, you can handle the `auth` option like this:
```toml
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
2018-03-01 07:42:03 +00:00
[entryPoints.foo]
2018-02-16 09:32:03 +00:00
address=":8080"
2018-03-01 07:42:03 +00:00
[entryPoints.foo.auth]
[entryPoints.foo.auth.basic]
2018-02-16 09:32:03 +00:00
users = [
"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
]
[api]
2018-03-01 07:42:03 +00:00
entrypoint="foo"
2018-02-16 09:32:03 +00:00
```
For more information, see [entry points ](/configuration/entrypoints/ ) .