openresty

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

From http://www.staticshin.com/programming/definitely-an-open-resty-guide/

http://www.londonlua.org/scriptingnginxwith_lua/slides.html

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

Rewritebylua
Accessbylua
Contentbylua
Initbylua
Setbylua

Rememeber to set luacodecache 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

及时获取更新,请关注公众号“爬虫技术学习(spider-learn)”

公众号“爬虫技术学习(spider-learn)”

About 逸飞

后端工程师

发表评论

电子邮件地址不会被公开。 必填项已用*标注