Skip to main content
Version: 2.8


Script represents a script that will be executed during the HTTP request/response life cycle.

The Script configuration can be directly bound to the Route.

Script and Plugin are mutually exclusive, and Script is executed first. This means that after configuring Script, the Plugin configured on Route will not be executed.

In theory, you can write arbitrary Lua code in Script, or you can directly call existing plugins to reuse existing code.

Script also has the concept of execution phase, supporting access, header_filter, body_filter and log phase. The system will automatically execute the code of the corresponding phase in the Script script in the corresponding phase.

{    ...    "script": "local _M = {} \n function _M.access(api_ctx) \n ngx.log(ngx.INFO,\"hit access phase\") \n end \nreturn _M"}