Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rewriteResponseBody as a middleware #15329

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/enterprise/traefik/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sources:
- https://github.com/traefik/traefik-helm-chart
- https://traefik.io/
type: application
version: 21.1.9
version: 21.1.10
annotations:
truecharts.org/category: network
truecharts.org/SCALE-support: "true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- range $index, $middlewareData := .Values.middlewares.rewriteResponseBody }}
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: {{ ternary (printf "%v-%v" $.Release.Name $middlewareData.name) $middlewareData.name $.Values.ingressClass.enabled }}
namespace: {{ $.Release.Namespace }}
spec:
plugin:
plugin-rewritebody:
lastModified: "true"
rewrites:
{{- range $index, $rewriteResponseBody := $middlewareData.headers }}
- regex: {{ $rewriteResponseBody.regex | quote }}
replacement: {{ $rewriteResponseBody.replacement | quote }}
{{- end }}
{{- end -}}
5 changes: 5 additions & 0 deletions charts/enterprise/traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ middlewares:
# - name: "Date"
# regex: "^[^,]+,\\s*(.+)$"
# replacement: "$1"
rewriteResponseBody: []
# - name: rewriteResponseBodyName
# headers:
# - regex = "foo"
# replacement = "bar"
customFrameOptionsValue: []
# - name: customFrameOptionsValueExample
# value: "SAMEORIGIN"
Expand Down
41 changes: 41 additions & 0 deletions templates/questions/traefik/rewriteResponseBodyMiddleware.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
- variable: rewriteResponseBody
label: Rewrite Response Body
schema:
type: list
default: []
items:
- variable: rewriteResponseBodyEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: Name
schema:
type: string
required: true
- variable: headers
label: HTML body sections to replace
schema:
type: list
default: []
items:
- variable: bodyEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: regex
label: Regex
description: The value of the HTML code to match. Accepts regex expression.
schema:
type: string
default: ""
- variable: replacement
label: Replacement Regex
description: The replacement HTML code to substitute. Accepts regex expression.
schema:
type: string
default: ""
Loading