diff --git a/charts/enterprise/traefik/Chart.yaml b/charts/enterprise/traefik/Chart.yaml index 1317f0f0c33a..0426f68c5b89 100644 --- a/charts/enterprise/traefik/Chart.yaml +++ b/charts/enterprise/traefik/Chart.yaml @@ -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" diff --git a/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml b/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml new file mode 100644 index 000000000000..7c95c4e2b16d --- /dev/null +++ b/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml @@ -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 -}} diff --git a/charts/enterprise/traefik/values.yaml b/charts/enterprise/traefik/values.yaml index b3f73ad87e12..ea911f119c04 100644 --- a/charts/enterprise/traefik/values.yaml +++ b/charts/enterprise/traefik/values.yaml @@ -338,6 +338,11 @@ middlewares: # - name: "Date" # regex: "^[^,]+,\\s*(.+)$" # replacement: "$1" + rewriteResponseBody: [] + # - name: rewriteResponseBodyName + # headers: + # - regex = "foo" + # replacement = "bar" customFrameOptionsValue: [] # - name: customFrameOptionsValueExample # value: "SAMEORIGIN" diff --git a/templates/questions/traefik/rewriteResponseBodyMiddleware.yaml b/templates/questions/traefik/rewriteResponseBodyMiddleware.yaml new file mode 100644 index 000000000000..7f98e0c4d646 --- /dev/null +++ b/templates/questions/traefik/rewriteResponseBodyMiddleware.yaml @@ -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: ""