Author: yifei / Created: May 30, 2017, 9:44 p.m. / Modified: May 30, 2017, 9:45 p.m. / Edit

  1. The *by_lua modules that tweak the nginx behaviour (for ex the rewrite_by_lua that is the lua equivalent of nginx http rewrite) module are always run after the standard nginx modules.
  2. The choice of *by_lua module to use largely depends upon the problem that you are trying to solve. For example the init_by_lua module is used for initialization operations where as access_by_lua may be used to implement access policies for a location block. Personally among the various directives I find most use for content_by_lua.


Lua can access nginx at different phase, the most important directives are:

Init_by_lua Set_by_lua

Rememeber to set lua_code_cache when developing

Use ngx.location.capture to issue a sub-request to other locations in nginx

ngx.ctx is a lua table to store data with a lifetime

有任何问题可以发邮件到 kongyifei (at) 讨论