Reputation: 1134
I would like to assign the value to the nginx variable.
This is my sample code.
location / {
set $TOKEN;
content_by_lua_block {
result = io.popen("echo 'https://google.com'") # or any command that will return value to result
ngx.var.TOKEN = result:read()
}
proxy_pass ${TOKEN};
Do anyone have idea about it?
Upvotes: 3
Views: 1594
Reputation: 1535
Use set_by_lua_block:
location / {
set $proxy '';
set_by_lua_block $proxy {
local result = io.popen("echo 'https://www.google.com'")
return result:read()
}
proxy_pass $proxy;
}
Upvotes: 4