9951 explained code solutions for 126 technologies


nginx-luaHow to access environment variables


env PATH;

http {
  #...
  
  server {
    location / {
      content_by_lua_block {
        ngx.say(os.getenv("PATH"))
      }
    }
  }
}ctrl + c
env PATH

we need to add env directive to core Nginx config to access needed environment variables (PATH in our case)

content_by_lua_block

nginx-lua module directive to specify block of Lua code

ngx.say

output given text to client

os.getenv

get specified environment variable value

PATH

sample environment variable to get value of