diff --git a/ingress/ingress.go b/ingress/ingress.go index 60ee87ac..cc23e1e0 100644 --- a/ingress/ingress.go +++ b/ingress/ingress.go @@ -3,6 +3,7 @@ package ingress import ( "fmt" "net" + "net/http" "net/url" "regexp" "strconv" @@ -260,7 +261,7 @@ func validateIngress(ingress []config.UnvalidatedIngressRule, defaults OriginReq if err != nil { return Ingress{}, errors.Wrap(err, "invalid HTTP status code") } - if statusCode < 100 || statusCode > 999 { + if http.StatusText(statusCode) == "" { return Ingress{}, fmt.Errorf("invalid HTTP status code: %d", statusCode) } srv := newStatusCode(statusCode) diff --git a/ingress/ingress_test.go b/ingress/ingress_test.go index 109cb353..9b8fd934 100644 --- a/ingress/ingress_test.go +++ b/ingress/ingress_test.go @@ -247,10 +247,18 @@ ingress: wantErr: true, }, { - name: "Invalid HTTP status code", + name: "Invalid HTTP status code(8080)", args: args{rawYAML: ` ingress: - service: http_status:8080 +`}, + wantErr: true, + }, + { + name: "Invalid HTTP status code(666)", + args: args{rawYAML: ` +ingress: + - service: http_status:666 `}, wantErr: true, },