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?
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;
}
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