You are browsing documentation for an outdated plugin version.
Configuration
This plugin is partially compatible with DB-less mode.
The plugin will run fine with the local
policy (which doesn’t use the database) or
the redis
policy (which uses an independent Redis, so it is compatible with DB-less).
The plugin will not work with the cluster
policy, which requires writes to the database.
Compatible protocols
The Rate Limiting plugin is compatible with the following protocols:
grpc
, grpcs
, http
, https
Parameters
Here's a list of all the parameters which can be used in this plugin's configuration:
-
name or plugin
string requiredThe name of the plugin, in this case
rate-limiting
.- If using the Kong Admin API, Konnect API, declarative configuration, or decK files, the field is
name
. - If using the KongPlugin object in Kubernetes, the field is
plugin
.
- If using the Kong Admin API, Konnect API, declarative configuration, or decK files, the field is
-
instance_name
stringAn optional custom name to identify an instance of the plugin, for example
rate-limiting_my-service
.The instance name shows up in Kong Manager and in Konnect, so it's useful when running the same plugin in multiple contexts, for example, on multiple services. You can also use it to access a specific plugin instance via the Kong Admin API.
An instance name must be unique within the following context:
- Within a workspace for Kong Gateway Enterprise
- Within a control plane or control plane group for Konnect
- Globally for Kong Gateway (OSS)
-
service.name or service.id
stringThe name or ID of the service the plugin targets. Set one of these parameters if adding the plugin to a service through the top-level
/plugins
endpoint. Not required if using/services/{serviceName|Id}/plugins
. -
route.name or route.id
stringThe name or ID of the route the plugin targets. Set one of these parameters if adding the plugin to a route through the top-level
/plugins
endpoint. Not required if using/routes/{routeName|Id}/plugins
. -
consumer.name or consumer.id
stringThe name or ID of the consumer the plugin targets. Set one of these parameters if adding the plugin to a consumer through the top-level
/plugins
endpoint. Not required if using/consumers/{consumerName|Id}/plugins
. -
consumer_group.name or consumer_group.id
stringThe name or ID of the consumer group the plugin targets. If set, the plugin will activate only for requests where the specified group has been authenticated
/plugins
endpoint. Not required if using/consumer_groups/{consumerGroupName|Id}/plugins
. -
enabled
boolean default:true
Whether this plugin will be applied.
-
config
record required-
second
numberThe number of HTTP requests that can be made per second.
-
minute
numberThe number of HTTP requests that can be made per minute.
-
hour
numberThe number of HTTP requests that can be made per hour.
-
day
numberThe number of HTTP requests that can be made per day.
-
month
numberThe number of HTTP requests that can be made per month.
-
year
numberThe number of HTTP requests that can be made per year.
-
limit_by
string default:consumer
Must be one of:consumer
,credential
,ip
,service
,header
,path
,consumer-group
The entity that is used when aggregating the limits.
-
header_name
stringA string representing an HTTP header name.
-
path
string starts_with:/
A string representing a URL path, such as /path/to/resource. Must start with a forward slash (/) and must not contain empty segments (i.e., two consecutive forward slashes).
-
policy
string default:local
len_min:0
Must be one of:local
,cluster
,redis
The rate-limiting policies to use for retrieving and incrementing the limits.
-
fault_tolerant
boolean required default:true
A boolean value that determines if the requests should be proxied even if Kong has troubles connecting a third-party data store. If
true
, requests will be proxied anyway, effectively disabling the rate-limiting function until the data store is working again. Iffalse
, then the clients will see500
errors.
-
redis
record requiredRedis configuration
-
host
stringA string representing a host name, such as example.com.
-
port
integer default:6379
between:0
65535
An integer representing a port number between 0 and 65535, inclusive.
-
timeout
integer default:2000
between:0
2147483646
An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
-
username
string referenceableUsername to use for Redis connections. If undefined, ACL authentication won’t be performed. This requires Redis v6.0.0+. To be compatible with Redis v5.x.y, you can set it to
default
.
-
password
string referenceable encrypted len_min:0
Password to use for Redis connections. If undefined, no AUTH commands are sent to Redis.
-
database
integer default:0
Database to use for the Redis connection when using the
redis
strategy
-
ssl
boolean default:false
If set to true, uses SSL to connect to Redis.
-
ssl_verify
boolean default:false
If set to true, verifies the validity of the server SSL certificate. If setting this parameter, also configure
lua_ssl_trusted_certificate
inkong.conf
to specify the CA (or server) certificate used by your Redis server. You may also need to configurelua_ssl_verify_depth
accordingly.
-
server_name
stringA string representing an SNI (server name indication) value for TLS.
-
-
hide_client_headers
boolean required default:false
Optionally hide informative response headers.
-
error_code
number default:429
Set a custom error code to return when the rate limit is exceeded.
-
error_message
string default:API rate limit exceeded
Set a custom error message to return when the rate limit is exceeded.
-
sync_rate
number required default:-1
How often to sync counter data to the central data store. A value of -1 results in synchronous behavior.
-
-
redis_host
stringDeprecation notice: This field is planned to be removed in version 4.0.
-
redis_port
integerDeprecation notice: This field is planned to be removed in version 4.0.
-
redis_password
string len_min:0
Deprecation notice: This field is planned to be removed in version 4.0.
-
redis_username
stringDeprecation notice: This field is planned to be removed in version 4.0.
-
redis_ssl
booleanDeprecation notice: This field is planned to be removed in version 4.0.
-
redis_ssl_verify
booleanDeprecation notice: This field is planned to be removed in version 4.0.
-
redis_server_name
stringDeprecation notice: This field is planned to be removed in version 4.0.
-
redis_timeout
integerDeprecation notice: This field is planned to be removed in version 4.0.
-
redis_database
integerDeprecation notice: This field is planned to be removed in version 4.0.