You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/waf/rate-limiting-rules/request-rate.mdx
+43-3Lines changed: 43 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ Consider the following configuration for a rate limiting rule:
55
55
56
56
-_Data center ID_ (included by default when creating the rule in the dashboard)
57
57
-_IP_
58
-
-_Headers_ > `x-api-key`
58
+
-_Header value of_ > `x-api-key`
59
59
60
60
</Example>
61
61
@@ -94,7 +94,7 @@ Consider the following configuration for a rate limiting rule. The rule counting
94
94
95
95
-_Data center ID_ (included by default when creating the rule in the dashboard)
96
96
-_IP_
97
-
-_Headers_ > `x-api-key`
97
+
-_Header value of_ > `x-api-key`
98
98
99
99
**Increment counter when**:
100
100
`http.request.uri.path eq "/form" and http.response.code eq 400`
@@ -135,4 +135,44 @@ Cloudflare keeps counters with the total score of all requests with the same val
135
135
136
136
If the origin server does not provide the HTTP response header with a score value or if the score value is outside of the allowed range, the corresponding rate limiting counter will not be updated.
137
137
138
-
For an example of a complexity-based rate limiting rule, refer to [Rule examples](/waf/rate-limiting-rules/use-cases/#example-4).
138
+
### Example C
139
+
140
+
Consider the following configuration for a rate limiting rule. When there is a rule match, the complexity score counter will increase based on the value in the `x-score` response header provided by the origin server.
141
+
142
+
<Example>
143
+
144
+
**_Rate limiting rule #3_**
145
+
146
+
**If incoming requests match**:<br />
147
+
`(http.request.uri.path eq "/graphql")`
148
+
149
+
**With the same value of** (characteristics):
150
+
151
+
-_Data center ID_ (included by default when creating the rule in the dashboard)
152
+
-_Header value of_ > `x-api-key`
153
+
154
+
**When rate exceeds**: _Complexity based_
155
+
156
+
- Score per period: `400`
157
+
- Period: _1 minute_
158
+
- Response header name: `x-score`
159
+
160
+
**Choose action**: _Block_
161
+
162
+
**With the following behavior**: _Block for the selected duration_
163
+
164
+
**Duration** (mitigation timeout): _10 minutes_
165
+
166
+
</Example>
167
+
168
+
The following diagram shows how Cloudflare handles four incoming requests received during a 1-minute period in the context of the above rate limiting rule.
169
+
170
+

171
+
172
+
Since request 1 matches the rule expression, the rate limiting rule is evaluated. The origin responds with a `200` status code and a complexity score of `100` in the `x-score` HTTP response header. Cloudflare creates a request counter for the values of the characteristics in the context of the rate limiting rule, and sets this counter to `100`.
173
+
174
+
Request 2 matches the rule expression and therefore Cloudflare evaluates the rate limiting rule. The request counter for the characteristics values is still within the maximum score per period. The origin responds with a `200` status code and the request counter is increased by `200`. The current complexity score for the request is now `300`.
175
+
176
+
Request 3 matches the rule expression and therefore Cloudflare evaluates the rate limiting rule. The request counter for the characteristics values is still within the maximum score per period. The origin responds with a `200` status code and the request counter is increased by `150`. The current complexity score for the request is now `450`.
177
+
178
+
Request 4 matches the rule expression and therefore Cloudflare evaluates the rate limiting rule. The request is no longer within the maximum score per period defined in the rule (the counter has the value `450` and the maximum score is `400`). Cloudflare applies the action defined in the rate limiting rule configuration, blocking request 4 and any later requests that match the rate limiting rule for ten minutes.
0 commit comments