Skip to content

Instantly share code, notes, and snippets.

@notsobad
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notsobad/9481689 to your computer and use it in GitHub Desktop.
Save notsobad/9481689 to your computer and use it in GitHub Desktop.
By notsobad.

TIPS

  • 修改完nginx配置之后,要运行nginx -t检查配置
  • lua中的print以notice日志打印到error_log中,所以需要开启notice日志,error_log /var/log/nginx/error.log notice; 参考: http://wiki.nginx.org/HttpLuaModuleZh#print
  • body_filter_by_lua可以用于修改响应, ngx.arg[1]为body正文,由于响应可能会分成多段,所以lua代码可能会触发多次,ngx.arg[2]为eof标记,当正文结束时,ngx.arg[2]为true
  • 设置lua_code_cache off,可以禁用*_by_lua_file的lua缓存,编辑lua代码之后,不需要reload nginx即可生效,这个指令对于content_by_lua之类写在nginx配置文件内部的lua代码无效。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment