2016-04-15 14:27:40 +00:00
# Examples
2017-03-31 04:29:03 +00:00
You will find here some configuration examples of Træfik.
2016-04-15 14:27:40 +00:00
## HTTP only
2017-04-30 18:17:57 +00:00
```toml
2016-04-15 14:27:40 +00:00
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
```
## HTTP + HTTPS (with SNI)
2017-04-30 18:17:57 +00:00
```toml
2016-04-15 14:27:40 +00:00
defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[[entryPoints.https.tls.certificates]]
CertFile = "integration/fixtures/https/snitest.com.cert"
KeyFile = "integration/fixtures/https/snitest.com.key"
[[entryPoints.https.tls.certificates]]
CertFile = "integration/fixtures/https/snitest.org.cert"
KeyFile = "integration/fixtures/https/snitest.org.key"
```
2016-07-11 15:32:28 +00:00
Note that we can either give path to certificate file or directly the file content itself ([like in this TOML example](/user-guide/kv-config/#upload-the-configuration-in-the-key-value-store)).
2016-04-15 14:27:40 +00:00
## HTTP redirect on HTTPS
2017-04-30 18:17:57 +00:00
```toml
2016-04-15 14:27:40 +00:00
defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[[entryPoints.https.tls.certificates]]
certFile = "tests/traefik.crt"
keyFile = "tests/traefik.key"
```
## Let's Encrypt support
2017-04-30 18:17:57 +00:00
```toml
2016-04-15 14:27:40 +00:00
[entryPoints]
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
# certs used as default certs
[[entryPoints.https.tls.certificates]]
certFile = "tests/traefik.crt"
keyFile = "tests/traefik.key"
[acme]
email = "test@traefik.io"
storageFile = "acme.json"
onDemand = true
caServer = "http://172.18.0.1:4000/directory"
entryPoint = "https"
[[acme.domains]]
main = "local1.com"
sans = ["test1.local1.com", "test2.local1.com"]
[[acme.domains]]
main = "local2.com"
sans = ["test1.local2.com", "test2x.local2.com"]
[[acme.domains]]
main = "local3.com"
[[acme.domains]]
main = "local4.com"
```
## Override entrypoints in frontends
2017-04-30 18:17:57 +00:00
```toml
2016-04-15 14:27:40 +00:00
[frontends]
[frontends.frontend1]
backend = "backend2"
[frontends.frontend1.routes.test_1]
rule = "Host:test.localhost"
[frontends.frontend2]
backend = "backend1"
passHostHeader = true
2017-04-06 22:10:02 +00:00
passTLSCert = true
2016-04-15 14:27:40 +00:00
entrypoints = ["https"] # overrides defaultEntryPoints
[frontends.frontend2.routes.test_1]
rule = "Host:{subdomain:[a-z]+}.localhost"
[frontends.frontend3]
entrypoints = ["http", "https"] # overrides defaultEntryPoints
backend = "backend2"
rule = "Path:/test"
```
2016-07-21 15:05:58 +00:00
## Enable Basic authentication in an entrypoint
With two user/pass:
- `test` :`test`
- `test2` :`test2`
Passwords are encoded in MD5: you can use htpasswd to generate those ones.
2017-04-30 18:17:57 +00:00
```toml
2016-07-21 15:05:58 +00:00
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.auth.basic]
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
2016-12-16 15:42:51 +00:00
```
## Pass Authenticated user to application via headers
Providing an authentication method as described above, it is possible to pass the user to the application
via a configurable header value
2017-04-30 18:17:57 +00:00
```toml
2016-12-16 15:42:51 +00:00
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.auth]
headerField = "X-WebAuth-User"
[entryPoints.http.auth.basic]
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
2017-04-04 09:36:23 +00:00
```
## Override the Traefik HTTP server IdleTimeout and/or throttle configurations from re-loading too quickly
2017-04-30 18:17:57 +00:00
```toml
2017-04-04 09:36:23 +00:00
IdleTimeout = "360s"
ProvidersThrottleDuration = "5s"
```