Lua Sequential Execution order

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.