docs, sticky session for Docker

This commit is contained in:
Owen Marshall 2016-06-02 14:36:14 -04:00 committed by Emile Vauge
parent d78c419627
commit be5b1fd92b
No known key found for this signature in database
GPG key ID: D808B4C167352E59
4 changed files with 20 additions and 0 deletions

View file

@ -222,6 +222,17 @@ For example:
- Another possible value for `extractorfunc` is `client.ip` which will categorize requests based on client source ip.
- Lastly `extractorfunc` can take the value of `request.header.ANY_HEADER` which will categorize requests based on `ANY_HEADER` that you provide.
Sticky sessions are supported with both load balancers. When sticky sessions are enabled, a cookie called `_TRAEFIK_BACKEND` is set on the initial
request. On subsequent requests, the client will be directed to the backend stored in the cookie if it is still healthy. If not, a new backend
will be assigned.
For example:
```toml
[backends]
[backends.backend1]
[backends.backend1.loadbalancer]
sticky = true
```
## Servers
Servers are simply defined using a `URL`. You can also apply a custom `weight` to each server (this will be used by load-balancing).

View file

@ -716,6 +716,7 @@ Labels can be used on containers to override default behaviour:
- `traefik.protocol=https`: override the default `http` protocol
- `traefik.weight=10`: assign this weight to the container
- `traefik.enable=false`: disable this container in Træfɪk
- `traefik.stickysession=true`: enable backend sticky sessions
- `traefik.frontend.rule=Host:test.traefik.io`: override the default frontend rule (Default: `Host:{containerName}.{domain}`).
- `traefik.frontend.passHostHeader=true`: forward client `Host` header to the backend.
- `traefik.frontend.priority=10`: override default frontend priority

View file

@ -439,6 +439,13 @@ func (provider *Docker) getWeight(container dockerData) string {
return "1"
}
func (provider *Docker) getSticky(container dockertypes.ContainerJSON) string {
if label, err := getLabel(container, "traefik.stickysession"); err == nil {
return true
}
return false
}
func (provider *Docker) getDomain(container dockerData) string {
if label, err := getLabel(container, "traefik.domain"); err == nil {
return label

View file

@ -7,6 +7,7 @@
{{if hasLoadBalancerLabel .}}
[backends.backend-{{getBackend .}}.loadbalancer]
method = "{{getLoadBalancerMethod .}}"
sticky = {{getSticky . }}
{{end}}
{{if hasMaxConnLabels .}}