I have an app that dynamically creates NGINX conf files. It then uses access_by_lua_file to process variables defined in the conf file.
e.g. conf file
location / {
set $_1 'value1'
set $_2 'value2'
set $_3 'value3'
set $_argc 3;
access_by_lua_file conf/mycode.lua;
}
In the lua code I need to create a lua (dict) table with these variables so I can use them for lookups. Currently I have a for loop (using _argc and builds a _# string to index ngx.var[''] ) that runs on each request to build this table. I'd like to avoid this rebuild each request.
I know global var in lua are bad. My understanding is set_by_lua runs each time to. I cant use init_by_lua since this is location specific.
Is there a way to statically define this map in standard nginx conf or lua?