feat(traefik): add customRequest/ResponseHeaders middlewares (#10401)
This commit is contained in:
parent
d23c3a6683
commit
fe7f2c03a2
|
@ -23,7 +23,7 @@ sources:
|
|||
- https://github.com/traefik/traefik-helm-chart
|
||||
- https://traefik.io/
|
||||
type: application
|
||||
version: 18.0.18
|
||||
version: 18.1.0
|
||||
annotations:
|
||||
truecharts.org/catagories: |
|
||||
- network
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# Adding or removing headers
|
||||
|
||||
The `customRequestHeaders` and `customResponseHeaders` middlewares will allow you to add or remove headers from the request or response.
|
||||
|
||||
## `customRequestHeaders`
|
||||
|
||||
You can specify a list of headers to add to requests. When removing a header, you only need to specify the header name (an empty value removes the header with that name from requests, if it exists).
|
||||
|
||||
## `customResponseHeaders`
|
||||
|
||||
You can specify a list of headers to add to responses. When removing a header, you only need to specify the header name (an empty value removes the header with that name from responses, if it exists).
|
|
@ -184,6 +184,8 @@ questions:
|
|||
attrs:
|
||||
# Include{basicAuthMiddleware}
|
||||
# Include{forwardAuthMiddleware}
|
||||
# Include{customRequestHeadersMiddleware}
|
||||
# Include{customResponseHeadersMiddleware}
|
||||
# Include{chainMiddleware}
|
||||
# Include{redirectSchemeMiddleware}
|
||||
# Include{rateLimitMiddleware}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{{- $values := .Values }}
|
||||
|
||||
{{ range $index, $middlewareData := .Values.middlewares.customRequestHeaders }}
|
||||
|
||||
---
|
||||
# Declaring the user list
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: {{ ternary (printf "%v-%v" $.Release.Name $middlewareData.name) $middlewareData.name $.Values.ingressClass.enabled }}
|
||||
namespace: tc-system
|
||||
spec:
|
||||
headers:
|
||||
customRequestHeaders:
|
||||
{{ range $index, $customRequestHeader := $middlewareData.headers }}
|
||||
{{ $customRequestHeader.name }}: {{ $customRequestHeader.value | quote }}
|
||||
{{ end }}
|
||||
{{ end }}
|
|
@ -0,0 +1,18 @@
|
|||
{{- $values := .Values }}
|
||||
|
||||
{{ range $index, $middlewareData := .Values.middlewares.customResponseHeaders }}
|
||||
|
||||
---
|
||||
# Declaring the user list
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: {{ ternary (printf "%v-%v" $.Release.Name $middlewareData.name) $middlewareData.name $.Values.ingressClass.enabled }}
|
||||
namespace: tc-system
|
||||
spec:
|
||||
headers:
|
||||
customResponseHeaders:
|
||||
{{ range $index, $customResponseHeader := $middlewareData.headers }}
|
||||
{{ $customResponseHeader.name }}: {{ $customResponseHeader.value | quote }}
|
||||
{{ end }}
|
||||
{{ end }}
|
|
@ -332,6 +332,20 @@ middlewares:
|
|||
# - "X-CustomHeader"
|
||||
# authResponseHeadersRegex: "^X-"
|
||||
# trustForwardHeader: true
|
||||
customRequestHeaders: []
|
||||
# - name: customRequestHeaderExample
|
||||
# headers:
|
||||
# - name: X-Custom-Header
|
||||
# value: "foobar"
|
||||
# - name: X-Header-To-Remove
|
||||
# value: ""
|
||||
customResponseHeaders: []
|
||||
# - name: customResponseHeaderExample
|
||||
# headers:
|
||||
# - name: X-Custom-Header
|
||||
# value: "foobar"
|
||||
# - name: X-Header-To-Remove
|
||||
# value: ""
|
||||
chain: []
|
||||
# - name: chainname
|
||||
# middlewares:
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
- variable: customRequestHeaders
|
||||
label: Custom Request Headers
|
||||
schema:
|
||||
type: list
|
||||
default: []
|
||||
items:
|
||||
- variable: customRequestHeadersEntry
|
||||
label: ""
|
||||
schema:
|
||||
additional_attrs: true
|
||||
type: dict
|
||||
attrs:
|
||||
- variable: name
|
||||
label: Name
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
- variable: headers
|
||||
label: Headers to Add
|
||||
schema:
|
||||
type: list
|
||||
default: []
|
||||
items:
|
||||
- variable: name
|
||||
label: Header Name
|
||||
description: Name of custom header to be added to requests, eg. X-Custom-Header
|
||||
pattern: ^[a-zA-Z0-9_\-]*$
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
default: ""
|
||||
- variable: value
|
||||
label: Header Value
|
||||
description: The value of the header. If the value is empty, the header will be removed.
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
default: ""
|
|
@ -0,0 +1,38 @@
|
|||
- variable: customResponseHeaders
|
||||
label: Custom Response Headers
|
||||
schema:
|
||||
type: list
|
||||
default: []
|
||||
items:
|
||||
- variable: customResponseHeadersEntry
|
||||
label: ""
|
||||
schema:
|
||||
additional_attrs: true
|
||||
type: dict
|
||||
attrs:
|
||||
- variable: name
|
||||
label: Name
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
- variable: headers
|
||||
label: Headers to Add
|
||||
schema:
|
||||
type: list
|
||||
default: []
|
||||
items:
|
||||
- variable: name
|
||||
label: Header Name
|
||||
description: Name of custom header to be added to responses, eg. X-Custom-Header
|
||||
pattern: ^[a-zA-Z0-9_\-]*$
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
default: ""
|
||||
- variable: value
|
||||
label: Header Value
|
||||
description: The value of the header. If the value is empty, the header will be removed.
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
default: ""
|
Loading…
Reference in New Issue