There is one issue here, a file read is only read at startup, any changes won't be passed until a restart.
Second, using such variable stuff is best done with Lua, https://github.com/chaoslawful/lua-nginx-module
discussions here https://groups.google.com/forum/#!forum/openresty-en
for example;
init_by_lua '
dsstr = {}; ds_as = 0;
local file = io.open("conf.d/cluster.mapping", "r");
for i = 1, count, 1 do
ds_line = file:read();
table.insert (dsstr, ds_line);
ds_as = ds_as + 1;
end
io.close (file);
';
To get flat data into an array,
Then you need init_worker_by_lua; with a timer (ngx.timer.at) to periodically check if the flatfile has changed.
Then you need set_by_lua in a location block to set values based on your Lua array.
It might be better to store this data in a database and query that for each request (which can be cached), for example see 'nginx GEOIP-MYSQL with Cache Non-Blocking.conf' in this archive http://nginx-win.ecsds.eu/download/ngxLuaDB-1.1.zip
Second, using such variable stuff is best done with Lua, https://github.com/chaoslawful/lua-nginx-module
discussions here https://groups.google.com/forum/#!forum/openresty-en
for example;
init_by_lua '
dsstr = {}; ds_as = 0;
local file = io.open("conf.d/cluster.mapping", "r");
for i = 1, count, 1 do
ds_line = file:read();
table.insert (dsstr, ds_line);
ds_as = ds_as + 1;
end
io.close (file);
';
To get flat data into an array,
Then you need init_worker_by_lua; with a timer (ngx.timer.at) to periodically check if the flatfile has changed.
Then you need set_by_lua in a location block to set values based on your Lua array.
It might be better to store this data in a database and query that for each request (which can be cached), for example see 'nginx GEOIP-MYSQL with Cache Non-Blocking.conf' in this archive http://nginx-win.ecsds.eu/download/ngxLuaDB-1.1.zip