title |
---|
Global rule |
Plugin just can be bound 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