9951 explained code solutions for 126 technologies

nginx-luaHow to use Luarocks and other modules in Nginx Lua

After installation of Luarocks module, we need to add its include path into Nginx Lua environment:

lua_package_path "/usr/local/share/lua/5.3/?.lua;";

init_by_lua_block {
  uuid = require("uuid")

server {
  location / {
    content_by_lua_block {
      local id = uuid()
}ctrl + c

specify include path for Lua modules


possible path to Luarocks installed modules (find your own path)


nginx-lua module directive to run specified Lua code on server startup


loads UUID Luarocks module


nginx-lua module directive to specify block of Lua code

local id = uuid()

UUID module sample usage