diff --git a/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml b/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml index 8a6df849e96c..7c95c4e2b16d 100644 --- a/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml +++ b/charts/enterprise/traefik/templates/middlewares/rewriteResponseBody.yaml @@ -10,8 +10,8 @@ spec: plugin-rewritebody: lastModified: "true" rewrites: - {{- range $index, $rewriteResponseHeader := $middlewareData.headers }} - - regex: {{ $rewriteResponseHeader.regex | quote }} - replacement: {{ $rewriteResponseHeader.replacement | quote }} + {{- 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: ""