Problem
You are following the steps mentioned at https://docs.traceable.ai/docs/openresty to install the Traceable Lua module. However you do not have the opm or the luarocks utility to install the dependent lua-resty-http module
If you go ahead without installing this dependency, the openresty/nginx will fail to start with the following error:
-- The job identifier is 632.
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: nginx: [error] init_by_lua error: ...ocal/openresty/nginx/conf/traceable/traceable-plugin.lua:309: module 'resty.http' not found:
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: no field package.preload['resty.http']
.....
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: stack traceback:
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: [C]: in function 'require'
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: ...ocal/openresty/nginx/conf/traceable/traceable-plugin.lua:309: in function <...ocal/openresty/nginx/conf/traceable/traceable-plugin.lua:300>
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: [C]: in function 'require'
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: ...ocal/openresty/nginx/conf/traceable/traceable-plugin.lua:25: in function <...ocal/openresty/nginx/conf/traceable/traceable-plugin.lua:16>
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: [C]: in function 'require'
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: ...ocal/openresty/nginx/conf/traceable/traceable-plugin.lua:1517: in main chunk
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: [C]: in function 'require'
May 09 23:04:12 ip-37-0-2-59 nginx[1097]: init_by_lua:2: in main chunk
May 09 23:04:12 ip-37-0-2-59 systemd[1]: openresty.service: Control process exited, code=exited, status=1/FAILURE
Pre-Requisite
To solve this, you would need:
- curl utility to download content from the internet
- To know the exact location that the lua modules are being loaded from. This can typically be looked up from your nginx.conf. eg:
lua_package_path "/usr/local/openresty/nginx/conf/traceable/?.lua;;";
Here the path in question that the openresty/nginx will load all the lua modules from is /usr/local/openresty/nginx/conf/traceable.
- To be able to download from the internet address:
https://raw.githubusercontent.com/ledgetech/lua-resty-http/v0.16.1
Solution
- Log on to the openresty server
- Change directory to the directory containing the lua modules and run the following command sequence:
cd /etc/nginx/lua/ # cd into the lua modules directory found in pre-req #2
sudo mkdir resty
cd resty
sudo curl https://raw.githubusercontent.com/ledgetech/lua-resty-http/v0.16.1/lib/resty/http.lua -o http.lua
sudo curl https://raw.githubusercontent.com/ledgetech/lua-resty-http/v0.16.1/lib/resty/http_connect.lua -o http_connect.lua
sudo curl https://raw.githubusercontent.com/ledgetech/lua-resty-http/v0.16.1/lib/resty/http_headers.lua -o http_headers.lua - Restart the openresty. eg on Ubuntu:
sudo /etc/init.d/openresty stop
sudo /etc/init.d/openresty start