Chain Middlewares
The chain middleware enables you to define reusable combinations of other pieces of middleware. It makes it effortless to reuse the same groups.
Below is an example of a chain containing:
- IngressRoute
- Chain Middleware
- Middlewares to chain
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: test
namespace: apps
spec:
entryPoints:
- web
routes:
- match: Host(`mydomain`)
kind: Rule
services:
- name: whoami
port: 80
middlewares:
- name: secured
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: secured
namespace: apps
spec:
chain:
middlewares:
- name: https-only
- name: known-ips
- name: auth-users
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: auth-users
spec:
basicAuth:
users:
- test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: https-only
spec:
redirectScheme:
scheme: https
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: known-ips
spec:
ipAllowList:
sourceRange:
- 192.168.1.7
- 127.0.0.1/32
Related Content
- See the Chain Middleware options in the dedicated section.