Reputation: 2414
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 ?
Upvotes: 3
Views: 2371
Reputation: 72312
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
.
Upvotes: 1