Libws 发表于 2023-8-14 14:25:07

关于宝塔Nginx防火墙的抽象问题导致Nginx崩溃的解决办法

本帖最后由 Libws 于 2023-8-14 15:06 编辑

我不用Apache防火墙,应该是没有的


如果你安装的是Nginx的Tengine/Openresty或者别的版本,甚至稳定版都可能都会遇到如下报错

启动失败:

nginx: failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found:
no field package.preload['resty.core']
no file '/www/server/btwaf/resty/core.lua'
no file '/www/server/nginx/site/lualib/resty/core.so'
no file '/www/server/nginx/lualib/resty/core.so'
no file './resty/core.so'
no file '/usr/local/lib/lua/5.1/resty/core.so'
no file '/www/server/nginx/luajit/lib/lua/5.1/resty/core.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/www/server/nginx/site/lualib/resty.so'
no file '/www/server/nginx/lualib/resty.so'
no file './resty.so'
no file '/usr/local/lib/lua/5.1/resty.so'
no file '/www/server/nginx/luajit/lib/lua/5.1/resty.so'
no file '/usr/local/lib/lua/5.1/loadall.so') in /www/server/nginx/conf/nginx.conf:96

不要惊慌,也不要去重装Nginx,加俩分号就能解决
去到/www/server/panel/vhost/nginx这个目录,打开btwaf.conf这个配置文件
定位到lua_package_path这一行,后面的内容应该是"/www/server/btwaf/?.lua",在?.lua的后面加上两个半角分号(;;)

完成后大概是这样:
lua_shared_dict spider 10m;
lua_shared_dict btwaf 30m;
lua_shared_dict drop_ip 30m;
lua_shared_dict drop_sum 30m;
lua_shared_dict btwaf_data 100m;
lua_package_path "/www/server/btwaf/?.lua;;";
init_by_lua_file/www/server/btwaf/init.lua;
access_by_lua_file /www/server/btwaf/waf.lua;
header_filter_by_lua_file /www/server/btwaf/header.lua;
body_filter_by_lua_file /www/server/btwaf/body.lua;

然后去重启Nginx就可以了,如果Nginx防火墙还是报错就去修面板吧
(宝塔啊,长点心吧,就俩分号都能漏了)

Libws 发表于 2023-8-14 14:28:11

如图所示

avhd 发表于 2023-9-18 04:51:41

牛逼啊,解决了(´゚Д゚`)

musk 发表于 2023-11-19 19:32:45

牛逼啊:lol:lol:lol:lol
页: [1]
查看完整版本: 关于宝塔Nginx防火墙的抽象问题导致Nginx崩溃的解决办法