9951 explained code solutions for 126 technologies


nginx-luaHow to write file


server {
  location / {
    content_by_lua_block {
      file = io.open('/tmp/hi.txt', 'w')
      file:write('hola')
      io.close(file)
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

io.open

opens specified file handler

/tmp/hi.txt

path to file to write

'w'

select this mode to be able to write to file

file:write

writes specified string to file

io.close

close file handler