Working with multiple Lua scripts in NGINX
Last updated 2021-05-22
Currently, NGINX only supports one init_by_lua
or init_by_lua_file
, which is used by the Signal Sciences NGINX module. If you have your own Lua scripts embedded within NGINX, you will need to splice the Signal Sciences module into your custom Lua code.
NOTE
By not using the sigsci.conf
configuration file, you will not receive configuration file updates when the module is upgraded. You should take care and review your Lua module when a Signal Sciences module release is updated.
Removing the Signal Sciences NGINX Lua Module
Before you add our module into your existing Lua code, you'll need to remove any references to the sigsci
include file: Look for and remove any lines that look like:
include /opt/sigsci/nginx/sigsci.conf;
Next, the following should be added to your NGINX configuration:
lua_shared_dict sigsci_conf 12k;lua_use_default_type off;
Within your init_by_lua
or the file specified by init_by_lua_file
, include the following snippet:
package.path = "/opt/sigsci/nginx/?.lua;" .. package.pathsigsci = require("SignalSciences")
Lastly, you will need to add an access_by_lua
and log_by_lua
into your NGINX configuration. If you already have these directives defined, copy the sigsci.prerequest()
and sigsci.postrequest()
statements to their respective Lua callers.
access_by_lua 'sigsci.prerequest()';log_by_lua 'sigsci.postrequest()';
After adding those lines to your custom Lua scripts, restart NGINX.
Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.