115 Star 698 Fork 166

GVPiresty / Apache APISIX

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
global-rule.md 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
title
Global Rule

Description

A Plugin configuration can be bound directly to a Route, a Service or a Consumer. But what if we want a Plugin to work on all requests? This is where we register a global Plugin with Global Rule.

Example

The example below shows how you can use the limit-count Plugin on all requests:

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
            }
        }
    }'

You can also list all the Global rules by making this request with the Admin API:

curl https://{apisix_listen_address}/apisix/admin/global_rules
Lua
1
https://gitee.com/iresty/apisix.git
git@gitee.com:iresty/apisix.git
iresty
apisix
Apache APISIX
master

搜索帮助