Hello!
On Sat, Nov 1, 2014 at 4:50 PM, Cefan Daniel Rubin wrote:
>
> Had the example I gave been more clear I may have seen the error meself:
> Turns out that the chain is:
>
> access_by_lua_file 'file1.lua';
> content_by_lua_file 'file2.lua';
>
> and since access_by_lua_file is not called in subrequests the ctx is not
> going to be changed by file1.lua.
>
Well, access_by_lua is not run at all in subrequests. This is documented:
https://github.com/openresty/lua-nginx-module#access_by_lua
"As with other access phase handlers, access_by_lua will not run in
subrequests."
According to the nginx's design, subrequests skip all the access phase
handlers, which is not specific to ngx_lua.
Maybe you should use rewrite_by_lua here instead?
BTW, given that you're already using content_by_lua in the same
location, it is recommended to merge all your Lua logic into one
handler, e.g., in your content_by_lua, because multiple *_by_lua
directive handlers add extra overhead as compared to a single *_by_lua
directive, for obvious reasons.
Regards,
-agentzh