Iterating on a proposal, we would like to propose a couple of changes for the current Headers middleware in Traefik.
First, we think this middleware has too many options, mixing both simple header manipulation and more "security-oriented" header fields in the same middleware can be confusing.
Also, having both request and response header fields handled by the same middleware does not necessarily make a lot of sense.
We propose to split the current headers
middleware into 3 distinct middleware:
-
requestHeader
, for manipulating request header fields only -
responseHeader
, for manipulating response header fields only -
secureHeader
, for handling all security-related header fields only
With this new split, we are currently considering the following configuration options for the new requestHeader
and responseHeader
middlewares:
Option n°1
Simple
For Kubernetes:
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: middleware-name
spec:
requestHeader:
set:
Header-Key-1: value1
For Docker:
labels:
- "traefik.http.middlewares.middleware-name.requestHeaders.set.Header-Key-1=value1"
Advanced
For Kubernetes:
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: middleware-name
spec:
requestHeader:
set:
Header-Key-1: value1
append:
Header-Key-2: value2
delete:
- Header-Key-3
- Header-Key-4
For Docker:
labels:
- "traefik.http.middlewares.middleware-name.requestHeaders.set.Header-Key-1=value1"
- "traefik.http.middlewares.middleware-name.requestHeaders.append.Header-Key-2=value2"
- "traefik.http.middlewares.middleware-name.requestHeaders.delete=Header-Key-3,Header-Key-4"
Option n°2
Simple
For Kubernetes:
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: middleware-name
spec:
requestHeader:
Header-Key-1:
value: value1
For Docker:
labels:
- "traefik.http.middlewares.middleware-name.requestHeader.Header-Key-1.value=value1"
Advanced
For Kubernetes:
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: middleware-name
spec:
requestHeader:
Header-Key-1:
value: value1
strategy: set # Default value, can be omitted.
Header-Key-2:
value: value2
strategy: append
Header-Key-3:
strategy: delete
Header-Key-4:
strategy: delete
For Docker:
labels:
- "traefik.http.middlewares.middleware-name.requestHeader.Header-Key-1.value=value1"
- "traefik.http.middlewares.middleware-name.requestHeader.Header-Key-2.value=value2"
- "traefik.http.middlewares.middleware-name.requestHeader.Header-Key-2.strategy=append"
- "traefik.http.middlewares.middleware-name.requestHeader.Header-Key-3.strategy=delete"
- "traefik.http.middlewares.middleware-name.requestHeader.Header-Key-4.strategy=delete"
- option 1
- option 2
0 voters