Lua#
The Lua package integrates the Lua programming language into Angie’s event-driven processing model, allowing the server’s functionality to be extended with Lua scripts. It consists of two modules:
lua-nginx-module
— openresty/lua-nginx-modulestream-lua-nginx-module
— openresty/stream-lua-nginx-module
Installation#
To install the module, use one of the following packages:
Angie:
angie-module-lua
;Angie PRO:
angie-pro-module-lua
.
Features#
Example use cases:
aggregating and processing output from various
upstream
servers (proxy, drizzle, postgres, redis, memcached, etc.);implementing access control and security logic before passing the request to the backend;
modifying response headers;
retrieving upstream server data from external sources and dynamically selecting the
upstream
;building complete web applications inside the
content handler
;performing URL routing during the rewrite phase;
implementing advanced caching for subrequests and
location
blocks.
The LuaJIT environment offers performance comparable to C, with high execution speed and low memory usage. This makes Lua integration especially efficient in Angie.
Loading the Module#
Using the Lua module requires loading the ndk
module beforehand.
Modules are loaded in the main{}
context as follows:
load_module modules/ndk_http_module.so;
load_module modules/ngx_http_lua_module.so; # for HTTP
load_module modules/ngx_stream_lua_module.so; # for Stream
Bundled Lua Libraries#
The following third-party libraries are installed along with the Lua modules:
Additional Information#
Comprehensive documentation and source code are available at: