leevis.com icon indicating copy to clipboard operation
leevis.com copied to clipboard

openresty 相关问题记录

Open vislee opened this issue 8 years ago • 0 comments

统计,记载openresty开发过程碰到的问题

问题

1 致循环引用错误,一般情况是lua脚本语法有问题,或者是找不到某个文件导致。 2 table传引用导致诡异问题出现。 3 ngx.shared.DICT.incr val要用tonumber()显示的转换。否则会包not a number。 4 lua_use_default_type 坑。因后端没有返回content-type,OpenResty使用默认的content-type导致浏览器解析有问题。

rewrite导致set变量的坑

问题描述

  • 在server块,用set指令设置了一个变量。例如:set $cache "off";
  • 在location的access阶段用lua脚本根据配置设置该变量。例如:ngx.var.cache = "on"
  • 在location中又添加了mirror指令。导致log阶段取到的变量还是off。例如:ngx.log(ngx.INFO, ngx.var.cache)
  • 把location中的mirror指令删掉。ngx.log(ngx.INFO, ngx.var.cache) 输出on。

问题来了,在content阶段,该变量是"on"还是"off"?这取决于在content阶段是否执行了mirror的子请求。那么子请求是在何时被调度执行的呢?

代码分析

vislee avatar Jun 09 '17 09:06 vislee