firebroo
V2EX  ›  编程

nginx + lua 全局变量传递问题

  •  
  •   firebroo · May 23, 2017 · 5777 views
    This topic created in 3453 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
    rrfeng
    May 23, 2017 via Android
    1
    test 他经历了什么
    firebroo
    firebroo
    OP
    May 23, 2017
    2
    @rrfeng access 到 body_filter 阶段它没经历啥。。
    htf176
    htf176
    May 23, 2017
    3
    subrequests 有自己的 ctx,Internal redirection 会清空 ctx
    firebroo
    firebroo
    OP
    May 24, 2017
    4
    @htf176 正解,是因为 internal redirection
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2955 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 11:18 · PVG 19:18 · LAX 03:18 · JFK 06:18
    ♥ Do have faith in what you're doing.