From 565f4576d7a30e3f880f947ff3c9820935c23abd Mon Sep 17 00:00:00 2001 From: Erlison Santos <98214640+MrErlison@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:57:00 -0300 Subject: [PATCH] Add CustomHTTPErrors directive (#11699) * Add CustomHTTPErrors directive * Fix: Add missing '=' in error_page directive --- internal/ingress/controller/template/crossplane/http.go | 5 +++++ .../controller/template/crossplane/testdata/nginx.tmpl | 1 + 2 files changed, 6 insertions(+) diff --git a/internal/ingress/controller/template/crossplane/http.go b/internal/ingress/controller/template/crossplane/http.go index d6dd81c133..09d6814116 100644 --- a/internal/ingress/controller/template/crossplane/http.go +++ b/internal/ingress/controller/template/crossplane/http.go @@ -284,6 +284,11 @@ func (c *Template) buildHTTP() { httpBlock = append(httpBlock, buildMapDirective("$http_referer", "$block_ref", refDirectives)) } + for _, v := range cfg.CustomHTTPErrors { + httpBlock = append(httpBlock, buildDirective("error_page", v, "=", + fmt.Sprintf("@custom_upstream-default-backend_%d", v))) + } + c.config.Parsed = append(c.config.Parsed, &ngx_crossplane.Directive{ Directive: "http", Block: httpBlock, diff --git a/internal/ingress/controller/template/crossplane/testdata/nginx.tmpl b/internal/ingress/controller/template/crossplane/testdata/nginx.tmpl index c65a400c45..ff68b1d9ae 100644 --- a/internal/ingress/controller/template/crossplane/testdata/nginx.tmpl +++ b/internal/ingress/controller/template/crossplane/testdata/nginx.tmpl @@ -407,6 +407,7 @@ http { default "$"; } + # MIGRATED {{ range $errCode := $cfg.CustomHTTPErrors }} error_page {{ $errCode }} = @custom_upstream-default-backend_{{ $errCode }};{{ end }}