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
This `SnippetsFilter` defines two Snippets to configure rate limiting. The first Snippet injects the value: `limit_req_zone \$binary_remote_addr zone=rate-limiting-sf:10m rate=1r/s;`
151
+
into the `http` context. The second Snippet injects the value: `limit_req zone=rate-limiting-sf burst=3;` into the location(s) generated for whichever route(s) reference this `SnippetsFilter`.
152
+
This `SnippetsFilter` will limit the request processing rate to 1 request per second.
Configure another rate limiting `SnippetsFilter` named `no-delay-rate-limiting-sf` by adding the following `SnippetsFilter`:
134
177
135
178
```yaml
136
179
kubectl apply -f - <<EOF
@@ -147,10 +190,9 @@ spec:
147
190
EOF
148
191
```
149
192
150
-
This `SnippetsFilter` defines two Snippets to configure rate limiting. The first Snippet injects the value: `limit_req_zone \$binary_remote_addr zone=no-delay-rate-limiting-sf:10m rate=1r/s;`
151
-
into the `http` context. The second Snippet injects the value: `limit_req zone=no-delay-rate-limiting-sf burst=3 nodelay;` into the location(s) generated for the routing rule.
152
-
This `SnippetsFilter` will limit the request processing rate to 1 request per second, and if there
153
-
are more than 3 requests in queue, it will throw a 503 error.
193
+
This `SnippetsFilter` is the same as the `rate-limiting-sf``SnippetsFilter`, however it adds the `nodelay` setting to the
194
+
`limit_req` directive in the Snippet targeting the `http.server.location` context. This will limit the request processing rate
195
+
to 1 request per second, and if there are more than 3 requests in queue, it will throw a 503 error.
154
196
155
197
Verify that the `SnippetsFilter` is Accepted:
156
198
@@ -174,7 +216,9 @@ Status:
174
216
Events: <none>
175
217
```
176
218
177
-
To use the `SnippetsFilter`, update the coffee HTTPRoute to reference it:
219
+
## Configure coffee to reference rate-limiting-sf SnippetsFilter
220
+
221
+
To use the `rate-limiting-sf``SnippetsFilter`, update the coffee HTTPRoute to reference it:
178
222
179
223
```yaml
180
224
kubectl apply -f - <<EOF
@@ -198,7 +242,7 @@ spec:
198
242
extensionRef:
199
243
group: gateway.nginx.org
200
244
kind: SnippetsFilter
201
-
name: no-delay-rate-limiting-sf
245
+
name: rate-limiting-sf
202
246
backendRefs:
203
247
- name: coffee
204
248
port: 80
@@ -229,7 +273,7 @@ Conditions:
229
273
Type: ResolvedRefs
230
274
```
231
275
232
-
Test that the `SnippetsFilter` is configured and has successfully applied the rate limiting NGINX configuration changes.
276
+
Test that the `rate-limiting-sf``SnippetsFilter` is configured and has successfully applied the rate limiting NGINX configuration changes.
233
277
234
278
Send a request to coffee:
235
279
@@ -251,67 +295,12 @@ set rate limit with a script that sends multiple requests.
You've successfully used Snippets with the `SnippetsFilter` resource to configure two distinct rate limiting rules to different backend applications.
401
+
402
+
In this example guide, the Cluster Operator would have played the role in creating and applying the `SnippetsFilter` resources shown in [Create Rate Limiting SnippetsFilters](#create-rate-limiting-snippetsfilters)
403
+
while the Application Developers for coffee and tea would have played the role in modifying their application to reference whichever `SnippetsFilter` they want shown in
404
+
[Configure coffee to reference rate-limiting-sf SnippetsFilter](#configure-coffee-to-reference-rate-limiting-sf-snippetsfilter) and [Configure tea to reference no-delay-rate-limiting-sf SnippetsFilter](#configure-tea-to-reference-no-delay-rate-limiting-sf-snippetsfilter).
405
+
This follows our recommended Role and Persona separation described in the [Best Practices when using SnippetsFilters](#best-practices-when-using-snippetsfilters).
393
406
394
-
This indicates that you've successfully used Snippets with the `SnippetsFilter` resource to configure two distinct rate limiting rules to different backend applications.
395
407
For an alternative method of modifying the NGINX configuration NGINX Gateway Fabric generates through Gateway API resources, check out
396
408
our supported [first-class policies]({{< relref "overview/custom-policies.md" >}}) which don't carry many of the aforementioned disadvantages of Snippets.
0 commit comments