docs, sticky session for Docker
This commit is contained in:
parent
d78c419627
commit
be5b1fd92b
4 changed files with 20 additions and 0 deletions
|
@ -222,6 +222,17 @@ For example:
|
||||||
- Another possible value for `extractorfunc` is `client.ip` which will categorize requests based on client source ip.
|
- 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.
|
- 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
|
||||||
|
|
||||||
Servers are simply defined using a `URL`. You can also apply a custom `weight` to each server (this will be used by load-balancing).
|
Servers are simply defined using a `URL`. You can also apply a custom `weight` to each server (this will be used by load-balancing).
|
||||||
|
|
|
@ -716,6 +716,7 @@ Labels can be used on containers to override default behaviour:
|
||||||
- `traefik.protocol=https`: override the default `http` protocol
|
- `traefik.protocol=https`: override the default `http` protocol
|
||||||
- `traefik.weight=10`: assign this weight to the container
|
- `traefik.weight=10`: assign this weight to the container
|
||||||
- `traefik.enable=false`: disable this container in Træfɪk
|
- `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.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.passHostHeader=true`: forward client `Host` header to the backend.
|
||||||
- `traefik.frontend.priority=10`: override default frontend priority
|
- `traefik.frontend.priority=10`: override default frontend priority
|
||||||
|
|
|
@ -439,6 +439,13 @@ func (provider *Docker) getWeight(container dockerData) string {
|
||||||
return "1"
|
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 {
|
func (provider *Docker) getDomain(container dockerData) string {
|
||||||
if label, err := getLabel(container, "traefik.domain"); err == nil {
|
if label, err := getLabel(container, "traefik.domain"); err == nil {
|
||||||
return label
|
return label
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
{{if hasLoadBalancerLabel .}}
|
{{if hasLoadBalancerLabel .}}
|
||||||
[backends.backend-{{getBackend .}}.loadbalancer]
|
[backends.backend-{{getBackend .}}.loadbalancer]
|
||||||
method = "{{getLoadBalancerMethod .}}"
|
method = "{{getLoadBalancerMethod .}}"
|
||||||
|
sticky = {{getSticky . }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasMaxConnLabels .}}
|
{{if hasMaxConnLabels .}}
|
||||||
|
|
Loading…
Reference in a new issue