Hello!
2015-04-28 9:22 GMT+08:00 Peng Wu:
> 在 ssl_cert_by_lua_file 中可以设置 ngx.ctx, 例如:
>
> ```
> ngx.ctx.hello = 100
> ```
>
> 不会报错,但在进入 access 阶段后,不能获取到 ngx.ctx.hello 的值。
>
> 是否在 ssl_cert_by_lua_file 中不能设置 ngx.ctx 呢?
>
可以在 ssl_certificate_by_lua_file 中设置 ngx.ctx,但这个 ngx.ctx 表会在
ssl_certificate_by_lua_file 结束运行时销毁。
这是因为这个上下文发生在非常早的阶段,即 SSL 握手阶段,此时在技术上无法保持 ngx.ctx
或者其他特定与请求的状态数据到请求上下文(包括 access 阶段),毕竟此时“请求”尚不存在。
Regards,
-agentzh