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: docs/en/latest/plugins/limit-count.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -344,6 +344,65 @@ Server: APISIX web server
344
344
{"error_msg":"Requests are too frequent, please try again later."}
345
345
```
346
346
347
+
### Customize Rate Limiting Headers
348
+
349
+
The following example demonstrates how you can use plugin metadata to customize the rate limiting response header names, which are by default `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset`.
350
+
351
+
Configure the plugin metadata for this plugin and update the headers:
352
+
353
+
```shell
354
+
curl "http://127.0.0.1:9180/apisix/admin/plugin_metadata/limit-count" -X PUT -d '
Create a route with `limit-count` plugin that allows for a quota of 1 within a 30-second window per remote address:
365
+
366
+
```shell
367
+
curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
368
+
-H "X-API-KEY: ${ADMIN_API_KEY}" \
369
+
-d '{
370
+
"id": "limit-count-route",
371
+
"uri": "/get",
372
+
"plugins": {
373
+
"limit-count": {
374
+
"count": 1,
375
+
"time_window": 30,
376
+
"rejected_code": 429,
377
+
"key_type": "var",
378
+
"key": "remote_addr",
379
+
"window_type": "sliding"
380
+
}
381
+
# highlight-end
382
+
},
383
+
"upstream": {
384
+
"type": "roundrobin",
385
+
"nodes": {
386
+
"httpbin.org:80": 1
387
+
}
388
+
}
389
+
}'
390
+
```
391
+
392
+
Send a request to verify:
393
+
394
+
```shell
395
+
curl -i "http://127.0.0.1:9080/get"
396
+
```
397
+
398
+
You should receive an `HTTP/1.1 200 OK` response and see the following headers:
399
+
400
+
```text
401
+
X-Custom-RateLimit-Limit: 1
402
+
X-Custom-RateLimit-Remaining: 0
403
+
X-Custom-RateLimit-Reset: 28
404
+
```
405
+
347
406
## Delete Plugin
348
407
349
408
To remove the `limit-count` Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.
0 commit comments