OpenResty配置WAF功能踩坑记录

图文教程请见: https://www.lixdx.cn/2021/05/04/nginx1/

waf的配置采用大神的github的方案:[链接 https://github.com/unixhot/waf](https://www.lixdx.cn/2021/05/04/nginx1/)

但是在部署到openresty的时候出现了如下的报错,无脑的在网上找到一篇文章,按照网上的说法配置了软简介都是无效的的,
最后发现还是得自己动脑子呀,还是得靠自己。

上面提到的文章链接为:https://blog.csdn.net/kabcko/article/details/106434236 访问量还不小

openrestu waf

openrestu waf

2021/05/04 11:05:07 [alert] 2030#2030: 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 ‘/usr/local/openresty/nginx/conf/waf/resty/core.lua’
no file ‘/usr/local/openresty/site/lualib/resty/core.so’
no file ‘/usr/local/openresty/lualib/resty/core.so’

我们仔细看这段报错发现是没有resty.core文件。
我们看下/usr/local/openresty/nginx/conf/waf/路径下到底有没有这个core.lua
查了一下果然是没有的,唉,问题应该就是这里了,接下来就是增加一个resy的软链接。

[root@lixdx conf]# ll waf/
总用量 24
-rw-r–r– 1 root root 408 5月 4 11:10 access.lua
-rw-r–r– 1 root root 1279 5月 4 11:10 config.lua
-rw-r–r– 1 root root 5473 5月 4 11:10 init.lua
-rw-r–r– 1 root root 2253 5月 4 11:10 lib.lua
lrwxrwxrwx 1 root root 34 5月 4 11:11 resty -> /usr/local/openresty/lualib/resty/
drwxr-xr-x 2 root root 4096 5月 4 10:47 rule-config
[root@lixdx conf]# nginx -t
nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
[root@lixdx conf]# nginx -s reload
[root@lixdx conf]#

再次查看启动日志,果然没有了报错。

//添加软连接之前
2021/05/04 11:05:07 [notice] 19572#19572: signal process started
2021/05/04 11:05:07 [alert] 2030#2030: 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 ‘/usr/local/openresty/nginx/conf/waf/resty/core.lua’
no file ‘/usr/local/openresty/site/lualib/resty/core.so’
no file ‘/usr/local/openresty/lualib/resty/core.so’
no file ‘./resty/core.so’
no file ‘/usr/local/lib/lua/5.1/resty/core.so’
no file ‘/usr/local/openresty/luajit/lib/lua/5.1/resty/core.so’
no file ‘/usr/local/lib/lua/5.1/loadall.so’
no file ‘/usr/local/openresty/site/lualib/resty.so’
no file ‘/usr/local/openresty/lualib/resty.so’
no file ‘./resty.so’
no file ‘/usr/local/lib/lua/5.1/resty.so’
no file ‘/usr/local/openresty/luajit/lib/lua/5.1/resty.so’
no file ‘/usr/local/lib/lua/5.1/loadall.so’) in /usr/local/openresty/nginx/conf/nginx.conf:125

//添加软连接之后

2021/05/04 11:12:29 [notice] 29514#29514: signal process started

接下来在网站上进行完全测试:
果然大功告成,记下来就是将日志安全日志接入ELK了。
下一篇文章分享。

上一篇:H7-TOOL的WiFi版基本成形,无线烧录,无线RTT,无线串口,无线CAN/CANFD,无线LUA小程序,无线示波器等,且支持局域网和外网


下一篇:redis笔记汇总