From d7e0e1e5764791113e50dc04362a808ae81ec833 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Wed, 17 Feb 2021 19:20:37 -0500 Subject: [PATCH] reverseproxy: Fix support for "4xx" type status codes --- modules/caddyhttp/reverseproxy/caddyfile.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go index 1592a5aa00d8..2835a1d2e4e0 100644 --- a/modules/caddyhttp/reverseproxy/caddyfile.go +++ b/modules/caddyhttp/reverseproxy/caddyfile.go @@ -1032,6 +1032,7 @@ func (h *Handler) parseNamedResponseMatcher(d *caddyfile.Dispenser, matchers map } matcher.Headers = http.Header(headerMatcher) + case "status": if matcher.StatusCode == nil { matcher.StatusCode = []int{} @@ -1043,12 +1044,16 @@ func (h *Handler) parseNamedResponseMatcher(d *caddyfile.Dispenser, matchers map } for _, arg := range args { + if len(arg) == 3 && strings.HasSuffix(arg, "xx") { + arg = arg[:1] + } statusNum, err := strconv.Atoi(arg) if err != nil { return d.Errf("bad status value '%s': %v", arg, err) } matcher.StatusCode = append(matcher.StatusCode, statusNum) } + default: return d.Errf("unrecognized response matcher %s", d.Val()) }