Add CustomHTTPErrors directive (#11699)

* Add CustomHTTPErrors directive

* Fix: Add missing '=' in error_page directive
This commit is contained in:
Erlison Santos 2024-07-31 15:57:00 -03:00 committed by Ricardo Katz
parent abb87ca750
commit 1ef5295ffe
2 changed files with 6 additions and 0 deletions

View file

@ -284,6 +284,11 @@ func (c *Template) buildHTTP() {
httpBlock = append(httpBlock, buildMapDirective("$http_referer", "$block_ref", refDirectives)) 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{ c.config.Parsed = append(c.config.Parsed, &ngx_crossplane.Directive{
Directive: "http", Directive: "http",
Block: httpBlock, Block: httpBlock,

View file

@ -407,6 +407,7 @@ http {
default "$"; default "$";
} }
# MIGRATED
{{ range $errCode := $cfg.CustomHTTPErrors }} {{ range $errCode := $cfg.CustomHTTPErrors }}
error_page {{ $errCode }} = @custom_upstream-default-backend_{{ $errCode }};{{ end }} error_page {{ $errCode }} = @custom_upstream-default-backend_{{ $errCode }};{{ end }}