mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-14 08:51:29 +08:00
1.6 KiB
1.6 KiB
title |
---|
Global rule |
Plugin just can be binded to Service or Route, if we want a Plugin work on all requests, how to do it?
We can register a global Plugin with GlobalRule
:
curl -X PUT \
https://{apisix_listen_address}/apisix/admin/global_rules/1 \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
-d '{
"plugins": {
"limit-count": {
"time_window": 60,
"policy": "local",
"count": 2,
"key": "remote_addr",
"rejected_code": 503
}
}
}'
Now, the limit-count
plugin will work on all requests
we can list all GlobalRule
via admin api as below:
curl https://{apisix_listen_address}/apisix/admin/global_rules