Improve middleware documentation.
This commit is contained in:
parent
fdb1701d1b
commit
dd62051e6c
1 changed files with 25 additions and 18 deletions
|
@ -16,9 +16,13 @@ Pieces of middleware can be combined in chains to fit every scenario.
|
||||||
```yaml tab="Docker"
|
```yaml tab="Docker"
|
||||||
# As a Docker Label
|
# As a Docker Label
|
||||||
whoami:
|
whoami:
|
||||||
image: containous/whoami # A container that exposes an API to show its IP address
|
# A container that exposes an API to show its IP address
|
||||||
|
image: containous/whoami
|
||||||
labels:
|
labels:
|
||||||
|
# Create a middleware named `foo-add-prefix`
|
||||||
- "traefik.http.middlewares.foo-add-prefix.addprefix.prefix=/foo"
|
- "traefik.http.middlewares.foo-add-prefix.addprefix.prefix=/foo"
|
||||||
|
# Apply the middleware named `foo-add-prefix` to the router named `router1`
|
||||||
|
- "traefik.http.router.router1.Middlewares=foo-add-prefix@docker"
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="Kubernetes"
|
```yaml tab="Kubernetes"
|
||||||
|
@ -61,20 +65,18 @@ spec:
|
||||||
|
|
||||||
```json tab="Marathon"
|
```json tab="Marathon"
|
||||||
"labels": {
|
"labels": {
|
||||||
"traefik.http.middlewares.foo-add-prefix.addprefix.prefix": "/foo"
|
"traefik.http.middlewares.foo-add-prefix.addprefix.prefix": "/foo",
|
||||||
|
"traefik.http.router.router1.Middlewares": "foo-add-prefix@marathon"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="Rancher"
|
```yaml tab="Rancher"
|
||||||
# As a Rancher Label
|
# As a Rancher Label
|
||||||
labels:
|
labels:
|
||||||
|
# Create a middleware named `foo-add-prefix`
|
||||||
- "traefik.http.middlewares.foo-add-prefix.addprefix.prefix=/foo"
|
- "traefik.http.middlewares.foo-add-prefix.addprefix.prefix=/foo"
|
||||||
```
|
# Apply the middleware named `foo-add-prefix` to the router named `router1`
|
||||||
|
- "traefik.http.router.router1.Middlewares=foo-add-prefix@rancher"
|
||||||
```toml tab="File"
|
|
||||||
[tlsOptions]
|
|
||||||
[tlsOptions.default]
|
|
||||||
minVersion = "VersionTLS12"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="Kubernetes"
|
```yaml tab="Kubernetes"
|
||||||
|
@ -115,25 +117,30 @@ spec:
|
||||||
Rule = "Host(`example.com`)"
|
Rule = "Host(`example.com`)"
|
||||||
|
|
||||||
[http.middlewares]
|
[http.middlewares]
|
||||||
[http.middlewares.foo-add-prefix.AddPrefix]
|
[http.middlewares.foo-add-prefix.AddPrefix]
|
||||||
prefix = "/foo"
|
prefix = "/foo"
|
||||||
|
|
||||||
[http.services]
|
[http.services]
|
||||||
[http.services.service1]
|
[http.services.service1]
|
||||||
[http.services.service1.LoadBalancer]
|
[http.services.service1.LoadBalancer]
|
||||||
|
|
||||||
[[http.services.service1.LoadBalancer.Servers]]
|
[[http.services.service1.LoadBalancer.Servers]]
|
||||||
URL = "http://127.0.0.1:80"
|
URL = "http://127.0.0.1:80"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Advanced Configuration
|
## Provider Namespace
|
||||||
|
|
||||||
When you declare a middleware, it lives in its `provider` namespace.
|
When you declare a middleware, it lives in its provider namespace.
|
||||||
For example, if you declare a middleware using a Docker label, under the hoods, it will reside in the docker `provider` namespace.
|
For example, if you declare a middleware using a Docker label, under the hoods, it will reside in the docker provider namespace.
|
||||||
|
|
||||||
If you use multiple `providers` and wish to reference a middleware declared in another `provider`, then you'll have to prefix the middleware name with the `provider` name.
|
If you use multiple providers and wish to reference a middleware declared in another provider,
|
||||||
|
then you'll have to prefix the middleware name with the provider name.
|
||||||
|
|
||||||
??? abstract "Referencing a Middleware from Another Provider"
|
```text
|
||||||
|
<resource-name>@<provider-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! abstract "Referencing a Middleware from Another Provider"
|
||||||
|
|
||||||
Declaring the add-foo-prefix in the file provider.
|
Declaring the add-foo-prefix in the file provider.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue