I am using HttpLuaModule for my NGINX server. I want to ask if it is possible to recognize variable in different directives of this module. For example
init_by_lua ' local global_var = 5 ' ;
some config ;
set_by_lua ' print(global_var) ' ;
How is that possible with NGINX and LUA module ?
If you want global_var to be global, don't declare it as local.
From a quick look at NGINX's docs, init_by_lua and set_by_lua work on the same global Lua state and so you'll be able to make them talk if you use global variables. Local variables set in init_by_lua will be lost.
So, it should work if you just remove local in init_by_lua.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With