diff --git a/internal/ingress/controller/template/crossplane/http.go b/internal/ingress/controller/template/crossplane/http.go index d6dd81c13..09d681411 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 c65a400c4..ff68b1d9a 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 }}