1.4.2. Lua sequence
Nginx under the LUA processing stage and scope of use:
Init_by_lua Httpset_by_lua Server, server if, location, location Ifrewrite_by_lua http, server, location, Location Ifaccess_by_lua http, server, location, location Ifcontent_by_lua, location ifheader_filter _by_lua http, server, location, location Ifbody_filter_by_lua http, server, location, location Iflog_by_lua http, server, location, location Iftimer
Init_by_lua: When Nginx reloads the configuration file, run the inside Lua script, which is often used for global variable applications. For example, Lua_shared_dict shared memory requests, only when Nginx restarts, the shared memory data is emptied, which is often used for statistics. Set_by_lua: Sets a variable that is commonly used with the calculation of a logic, and then returns the result that phase cannot run the output API, Control API, Subrequest API, Cosocket Apirewrite_by_lua: Run before the access stage, primarily for Rewriteaccess_by_lua: mainly for access control, to collect most variables, and similar status to be in the log phase. This instruction runs at the end of the Nginx access phase and therefore always runs after commands such as allow and deny, although they belong to the access phase. Content_by_lua: The stage is the most important of all request processing phases, and the configuration directives that run at this stage generally carry the generated content and output the HTTP response. Header_filter_by_lua: Generally only used for setting cookies and headers, etc. this stage cannot run the output API, Control API, Subrequest API, Cosocket apibody_filter_by _lua: It is typically called multiple times in a single request, because this is the so-called "streaming output" that implements HTTP 1.1 chunked encoding. This phase cannot run the output API, Control API, Subrequest API, Cosocket Apilog_by_lua: This phase always runs at the end of the request, for subsequent operations of the request, such as statistics in shared memory, If you want high-precision data statistics, you should use Body_filter_by_lua. This phase cannot run the output API, Control API, Subrequest API, Cosocket Apitimer:
Refer to the official documentation:
Http://wiki.nginx.org/HttpLuaModule
Lua Sequential Execution order