参数
有关所有插件均可使用的配置项,请参阅插件通用配置。
rate
number
必填
有效值:
大于 0
每秒允许的最大请求数。超过此速率但低于 burst 的请求将被延迟。
burst
number
必填
有效值:
大于或等于 0
每秒允许延迟处理的请求数(用于流量整形)。超过 rate 和 burst 总和的请求将被拒绝。
key_type
string
默认值:
var有效值:
var或var_combination键的类型。
如果
key_type为var,则key被解释为变量。如果
key_type为var_combination,则key被解释为变量组合。key
string
必填
用于计数请求的键。
如果
key_type为var,则key被解释为变量。变量不需要以美元符号($)作为前缀。查看内置变量以获取可用变量。如果
key_type为var_combination,则key被解释为变量组合。所有变量都应以美元符号($)作为前缀。例如,要将key配置为使用两个请求头custom-a和custom-b的组合,key应配置为$http_custom_a $http_custom_b。rejected_code
integer
默认值:
503有效值:
介于 200 和 599 之间(含边界值)
当请求因超过阈值而被拒绝时返回的 HTTP 状态码。
rejected_msg
string
有效值:
任意非空字符串
当请求因超过阈值而被拒绝时返回的响应体。
nodelay
boolean
默认值:
false如果为 true,则不延迟 burst 阈值内的请求。
allow_degradation
boolean
默认值:
false如果为 true,则在插件或其依赖项不可用时,允许网关继续处理请求而不使用该插件。
policy
string
默认值:
local有效值:
local、redis或redis-cluster速率限制计数器的策略。如果为
local,则计数器存储在本地内存中。如 果为redis,则计数器存储在 Redis 实例中。如果为redis-cluster,则计数器存储在 Redis 集群中。如果你使用的是 API7 企业版,该选项从版本 3.9.0 开始可用。
redis_host
string
Redis 节点的地址。当
policy为redis时必填。redis_port
integer
默认值:
6379有效值:
大于或等于 1
Redis 节点的端口。当
policy为redis时使用。redis_username
string
如果使用 Redis ACL,则为 Redis 的用户名。如果你使用传统的认证方法
requirepass,则只需配置redis_password。当policy为redis时使用。redis_password
string
Redis 节点的密码。当
policy为redis或redis-cluster时使用。API7 Gateway 自 3.10.2 起会在保存到数据库前使用 AES256 加密该值;APISIX 自 3.18.0 起会在存储到 etcd 前使用 AES 加密该值。redis_database
integer
默认值:
0有效值:
大于或等于 0
Redis 中的数据库编号。当
policy为redis时使用。redis_ssl
boolean
默认值:
false如果为 true,则在
policy为redis时使用 SSL 连接到 Redis。redis_ssl_verify
boolean
默认值:
false如果为 true,则在
policy为redis时验证服务器 SSL 证书。redis_timeout
integer
默认值:
1000有效值:
大于或等于 1
Redis 超时时间(毫秒)。当
policy为redis或redis-cluster时使用。redis_keepalive_timeout
integer
默认值:
10000有效值:
大于或等于 1000
当
policy为redis或redis-cluster时,Redis 的 keepalive 超时时间(毫秒)。此参数在 APISIX 3.15.0 版本中可用,尚未在 API7 企业版中提供。
redis_keepalive_pool
integer
默认值:
100有效值:
大于或等于 1
当
policy为redis或redis-cluster时,Redis 的 keepalive 连接池大小。此参数在 APISIX 3.15.0 版本中可用,尚未在 API7 企业版中提供。
redis_cluster_nodes
array[string]
Redis 集群节点列表,至少包含两个地址。当
policy为redis-cluster时必填。redis_cluster_name
string
Redis 集群的名称。当
policy为redis-cluster时必填。redis_cluster_ssl
boolean
默认值:
false如果为 true,则在
policy为redis-cluster时使用 SSL 连接到 Redis 集群。redis_cluster_ssl_verify
boolean
默认值:
false如果为 true,则在
policy为redis-cluster时验证服务器 SSL 证书。