V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
firebroo
V2EX  ›  编程

nginx + lua 全局变量传递问题

  •  
  •   firebroo · May 23, 2017 · 5366 views
    This topic created in 3273 days ago, the information mentioned may be changed or developed.
    我 access 阶段设置了一个变量 ngx.ctx.test=1, 我在 body_filter 阶段访问的时候取到这个 ngx.ctx.test 变量的值为空,我本来认为任何一个请求都会经历 access 这个阶段,所以 ngx.ctx.test 的值必然会被设置,但是现在根据我遭遇的情况好像并不是这么回事?或者也可能是经历了啥情况把 ngx.ctx 的所有变量都清空了?

    并不是所有请求都出现这个,而是几十万请求出现了一次
    4 replies    2017-05-24 10:25:52 +08:00
    rrfeng
        1
    rrfeng  
       May 23, 2017 via Android
    test 他经历了什么
    firebroo
        2
    firebroo  
    OP
       May 23, 2017
    @rrfeng access 到 body_filter 阶段它没经历啥。。
    htf176
        3
    htf176  
       May 23, 2017
    subrequests 有自己的 ctx,Internal redirection 会清空 ctx
    firebroo
        4
    firebroo  
    OP
       May 24, 2017
    @htf176 正解,是因为 internal redirection
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5230 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 03:52 · PVG 11:52 · LAX 20:52 · JFK 23:52
    ♥ Do have faith in what you're doing.