Parameters
See plugin common configurations for configuration options available to all plugins.
All parameters can be configured using environment variables. For example, you can save Redis password to an environment variable REDIS_PASSWORD and configure redis_password to be $env://REDIS_PASSWORD.
count
integer
required
vaild vaule:
greater than 0
The maximum number of requests allowed within a given time interval.
time_window
integer
required
vaild vaule:
greater than 0
The time interval corresponding to the rate limiting
countin seconds.key_type
string
default:
varvaild vaule:
var,var_combination, orconstantThe type of key.
If the
key_typeisvar, thekeyis interpreted a variable.If the
key_typeisvar_combination, thekeyis interpreted as a combination of variables.If the
key_typeisconstant, thekeyis interpreted as a constant.key
string
default:
remote_addrThe key to count requests by.
If the
key_typeisvar, thekeyis interpreted a variable. The variable does not need to be prefixed by a dollar sign ($). See built-in variables for avaialble variables.If the
key_typeisvar_combination, thekeyis interpreted as a combination of variables. All variables should be prefixed by dollar signs ($). For example, to configure thekeyto use a combination of two request headerscustom-aandcustom-b, thekeyshould be configured as$http_custom_a $http_custom_b.If the
key_typeisconstant, thekeyis interpreted as a constant value.rejected_code
integer
default:
503vaild vaule:
between 200 and 599 inclusive
The HTTP status code returned when a request is rejected for exceeding the threshold.
rejected_msg
string
default:
503vaild vaule:
any non-empty string
The response body returned when a request is rejected for exceeding the threshold.
policy
string
default:
localvaild vaule:
local,redis, orredis-clusterThe policy for rate limiting counter. If it is
local, the counter is stored in memory locally. If it isredis, the counter is stored on a Redis instance. If it isredis-cluster, the counter is stored in a Redis cluster.allow_degradation
boolean
default:
falseif true, allow APISIX to continue handling requests without the plugin when the plugin or its dependencies become unavailable.
show_limit_quota_header
boolean
default:
trueif true, include
X-RateLimit-Limitto show the total quota andX-RateLimit-Remainingto show the remaining quota in the response header.group
string
vaild vaule:
non-empty
The
groupID for the plugin, such that routes of the samegroupcan share the same rate limiting counter.redis_host
string
The address of the Redis node. Required when
policyisredis.redis_port
integer
default:
6379vaild vaule:
greater or equal to 1
The port of the Redis node when
policyisredis.redis_username
string
The username for Redis if Redis ACL is used. If you use the legacy authentication method
requirepass, configure only theredis_password. Used whenpolicyisredis.redis_password
string
default:
6379The password of the Redis node when
policyisredisorredis-cluster.redis_database
integer
default:
0vaild vaule:
greater or equal to 0
The database number in Redis when
policyisredis.redis_ssl
boolean
default:
falseif true, use SSL to connect to Redis cluster when
policyisredis.redis_ssl_verify
boolean
default:
falseif true, verify the server SSL certificate when
policyisredis.redis_timeout
integer
default:
1000vaild vaule:
greater or equal to 1
The Redis timeout value in milliseconds when
policyisredisorredis-cluster.redis_cluster_nodes
array[string]
The list of the Redis cluster nodes with at least two addresses. Required when policy is redis-cluster.
redis_cluster_name
string
The name of the Redis cluster. Required when
policyisredis-cluster.redis_cluster_ssl
boolean
default:
falseif true, use SSL to connect to Redis cluster when
policyisredis-cluster.redis_cluster_ssl_verify
boolean
default:
falseif true, verify the server SSL certificate when
policyisredis-cluster.sync_interval
number
default:
-1vaild vaule:
greater than or equal to 0.1, or the default -1
The frequency of synchronizing counter data to Redis. Available only in Enterprise.
The
sync_intervalvalue should be smaller thantime_window. A value of1results in synchronizing counter data every second. A value of-1yields no change in synchronizing behaviour, i.e. counter data will be synchronized for each request.