Skip to content

Commit

Permalink
[WAF] Clarify wording re: counting expression extending matching expr…
Browse files Browse the repository at this point in the history
…ession (cloudflare#10503)


---------

Co-authored-by: Pedro Sousa <[email protected]>
  • Loading branch information
bregenspan and Pedro Sousa authored Aug 30, 2023
1 parent 9ae6588 commit 15108e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions content/waf/rate-limiting-rules/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ Use _IP with NAT support_ to handle situations such as requests under NAT sharin

- Field name in the API: `counting_expression` (optional).
- Only available in the Cloudflare dashboard when you enable **Use custom counting expression**.
- Defines the criteria used for determining the request rate. By default, the counting expression is the same as the rule expression. This default is also applied when you set this field to an empty string (`""`).
- The counting expression does not extend the rule matching expression defined in **If incoming requests match**. Therefore, you may wish to include the matching expression in the counting expression. For example, you might want to perform rate limiting for clients sending more than five requests to `/api/` resulting in a `403` HTTP status code from the origin server. In this case, the matching expression would be `starts_with(http.request.uri.path, "/api/")` and the counting expression would be `http.response.code eq 403 and starts_with(http.request.uri.path, "/api/")`. If the counting expression did not include the matching expression (that is, if you had set the counting expression to `http.response.code eq 403`), any response with a `403` status code on any URL would increase the counter.
- Defines the criteria used for determining the request rate. By default, the counting expression is the same as the rule matching expression (defined in **If incoming requests match**). This default is also applied when you set this field to an empty string (`""`).
- If you set a custom counting expression, it will not automatically extend the rule matching expression. Therefore, you may wish to include the matching expression in the counting expression. For example, you might want to perform rate limiting for clients sending more than five requests to `/api/` resulting in a `403` HTTP status code from the origin server. In this case, the matching expression would be `starts_with(http.request.uri.path, "/api/")` and the counting expression would be `http.response.code eq 403 and starts_with(http.request.uri.path, "/api/")`. If the counting expression did not include the matching expression (that is, if you had set the counting expression to `http.response.code eq 403`), any response with a `403` status code on any URL would increase the counter.
- The counting expression can include [HTTP response fields](/ruleset-engine/rules-language/fields/#http-response-fields). When there are response fields in the counting expression, the counting will happen after the response is sent.
- In some cases, you cannot include HTTP response fields in the counting expression due to configuration restrictions. Refer to [Configuration restrictions](#configuration-restrictions) for details.

Expand Down

0 comments on commit 15108e1

Please sign in to comment.