Lua scripting with reverse proxy
Reverse proxy supports dynamic evaluation of HTTP fallback requests that use Lua scripting.
Lua scripts can be used to allow, reject, or modify HTTP fallback transfer requests in real time as they are received by the Proxy server. Lua scripts have access to the HTTP request information such as body, headers, and URL. The Lua scripting facility is included in the Nginxâ„¢ software that is distributed with Proxy.
Configuring Lua
The primary configuration file for Lua is /etc/nginx/nginx.conf. To enable the importing of external Lua libraries, either compiled or written in Lua, set lua_package_path and lua_package_cpath in the nginx.conf file. These settings must be inside the http directive and precede any server directives.
http {
...
# set search paths for pure Lua external libraries (';;' is the default path):
lua_package_path '/opt/aspera/nginx/lua/?.lua;;';
# set search paths for Lua external libraries written in C (can also use ';;'):
lua_package_cpath '/opt/aspera/nginx/lua/?.so;;';
server {
...
}
}
This allows sources in /opt/aspera/nginx/lua to be imported by using a require statement.
Running your scripts
To start your Lua scripts, use a content_by_lua or access_by_lua block in a location directive. For example,
server {
...
location /url/path/to/resource {
content_by_lua 'ngx.say("Hello world")'
}
https://github.com/openresty/lua-nginx-module#readme
Errors
/opt/aspera/nginx/logs/error.log
Limitations
The Nginx component of Proxy was not compiled with luaJIT. For this reason, the *_block directives cannot be used. For example, content_by_lua_block and access_by_lua_block are not available; use content_by_lua or access_by_lua instead.