9951 explained code solutions for 126 technologies


nginx-luaHow to set Nginx variable


server {
  location / {
    set_by_lua_block $test {
      return os.time()
    }
    
    return 200 $test;
  }
}ctrl + c
set_by_lua_block

nginx-lua module directive that sets specified variable with a result from Lua code

return os.time()

sample Lua code that returns current unix timestamp

$test

this variable will contain value returned by Lua code

return 200 $test;

here we just send $test variable value to client