Skip to main content
Version: 2.12

Global rule

The Plugin configuration can be bound directly to a Route, or to a Service or Consumer. What if we want a Plugin to 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