This article describes how to use the Lua script in nginx. The third-party module LUA-nginx-module is used to call the Lua script in nginx. A Configuration example is provided.
Lua is a language similar to Javascript. ngix_lua also uses asynchronous single-thread, and its syntax is even simpler than Js. According to previous evaluations, the performance of ngix_lua is almost node. JS.
Nginx features
1. Popular High-Performance HTTP servers
2. event-driven (asynchronous) Architecture
3. A small amount of memory can be measured
4. Declarative configuration language
5. C-based scalable modules
You can use LUA-nginx-module to start the Lua script on nginx.
Example:
Location/{content_by_lua 'local res = ngx. location. capture ("/Sub") if res. status> = 500 then ngx. exit (res. status) end ngx. status = res. status ngx. say (res. body) ';} location/sub {echo "Hello, sub-request! ";}
Lua-nginx-module on GitHub Project address https://github.com/openresty/lua-nginx-module