Protects a Service or a Route from most common bots and has the capability of whitelisting and blacklisting custom clients.
Terminology
plugin
: a plugin executing actions inside IAM before or after a request has been proxied to the upstream API.Service
: the IAM entity representing an external upstream API or microservice.Route
: the IAM entity representing a way to map downstream requests to upstream services.upstream service
: this refers to your own API/service sitting behind IAM, to which client requests are forwarded.
Configuration
This plugin is compatible with requests with the following protocols:
http
https
This plugin is compatible with DB-less mode.
Enabling the plugin on a Service
With a database
Configure this plugin on a Service by making the following request:
$ curl -X POST http://localhost:8001/services/{service}/plugins \
--data "name=bot-detection"
Without a database
Configure this plugin on a Service by adding this section do your declarative configuration file:
plugins:
- name: bot-detection
service: {service}
config:
In both cases, {service}
is the id
or name
of the Service that this plugin configuration will target.
Enabling the plugin on a Route
With a database
Configure this plugin on a Route with:
$ curl -X POST http://localhost:8001/routes/{route}/plugins \
--data "name=bot-detection"
Without a database
Configure this plugin on a Route by adding this section do your declarative configuration file:
plugins:
- name: bot-detection
route: {route}
config:
In both cases, {route}
is the id
or name
of the Route that this plugin configuration will target.
Global plugins
- Using a database, all plugins can be configured using the
http://localhost:8001/plugins/
endpoint. - Without a database, all plugins can be configured via the
plugins:
entry on the declarative configuration file.
A plugin which is not associated to any Service, Route or Consumer (or API, if you are using an older version of IAM) is considered "global", and will be run on every request. Read the Plugin Reference and the Plugin Precedence sections for more information.
Parameters
Here's a list of all the parameters which can be used in this plugin's configuration:
form parameter | description |
---|---|
name | The name of the plugin to use, in this case bot-detection |
service_id | The id of the Service which this plugin will target. |
route_id | The id of the Route which this plugin will target. |
enabled default value: true | Whether this plugin will be applied. |
config.whitelist
optional |
An array of regular expressions that should be whitelisted. The regular expressions will be checked against the |
config.blacklist
optional |
An array of regular expressions that should be blacklisted. The regular expressions will be checked against the |
Default rules
The plugin already includes a basic list of rules that will be checked on every request. You can find this list on GitHub at https://github.com/Kong/kong/blob/master/kong/plugins/bot-detection/rules.lua.