I have nginx
in a docker container, where FORWARD_LOG
env variable has value 1.
In nginx.conf
:
env FORWARD_LOG;
My server config:
server {
listen 80 default_server;
server_name nginx;
location / {
#resolvers
#resolvers_template
set_by_lua $forward_log 'return os.getenv("FORWARD_LOG")';
proxy_pass $scheme://$host$request_uri;
lua_code_cache on;
access_by_lua_file /etc/nginx/domain.lua;
allow all;
}
}
Now I want to get this variable in domain.lua
script. I tried different methods:
local FORWARD_LOG = ngx.var.forward_log;
gives an empty result.
local FORWARD_LOG = $forward_log;
gives unexpected symbol near '$'
.
local FORWARD_LOG = os.getenv("FORWARD_LOG")';
- returns nil
.
How can I do that ?