title |
---|
Plugin |
This represents the configuration of the plugins that are executed during the HTTP request/response lifecycle. A Plugin configuration can be bound directly to a Route
, a Service
or a Consumer
.
:::note
While configuring the same plugin, only one copy of the configuration is valid. The order of precedence is always Consumer
> Route
> Service
.
While configuring APISIX, you can declare the Plugins that are supported by the local APISIX node. This acts as a whitelisting mechanism as Plugins that are not in this whitelist will be automatically ignored. So, this feature can be used to temporarily turn off/turn on specific plugins.
For adding new plugins based on existing plugins, copy the data in the plugins
node from the default configuration file conf/config-default.yaml
to your configuration file (conf/config.yaml
).
In a request, a Plugin is only executed once. This is true even if it is bound to multiple different objects like Routes and Services. The order in which Plugins are run is determined by its configured priorities:
local _M = {
version = 0.1,
priority = 0, -- the priority of this plugin will be 0
name = plugin_name,
schema = schema,
metadata_schema = metadata_schema,
}
A Plugin configuration is submitted as part of the Route or Service and is placed under plugins
. It internally uses the Plugin name as the hash key to holding the configuration items for the different Plugins.
{
...
"plugins": {
"limit-count": {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
},
"prometheus": {}
}
}
Not all Plugins have specific configuration items (for example, prometheus). In such cases, an empty object identifier can be used.
A warning level log as shown below indicates that the request was rejected by the Plugin.
ip-restriction exits with http status code 403
APISIX Plugins are hot-loaded. This means that there is no need to restart the service if you add, delete, modify plugins, or even if you update the plugin code. To hot-reload, you can send an HTTP request through the Admin API:
curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
:::note
If a configured Plugin is disabled, then its execution will be skipped.
For hot-reloading in stand-alone mode, see the plugin related section in stand alone mode.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。