OpenWAF icon indicating copy to clipboard operation
OpenWAF copied to clipboard

nginx+lua+Openwaf:nginx语法检测报lua文件找不到相关错误

Open gitboy123 opened this issue 7 years ago • 8 comments

/data/server/nginx-1.14/sbin/nginx -V

nginx version: JYWS/2.1.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.1.0h 27 Mar 2018 TLS SNI support enabled configure arguments: --prefix=/data/server/nginx-1.14 --with-http_v2_module --with-stream --with-http_gunzip_module --with-http_ssl_module --with-threads --with-file-aio --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_image_filter_module --with-http_auth_request_module --with-http_random_index_module --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib --with-pcre=/data/server/nginx-waf/module/pcre-8.42 --with-zlib=/data/server/nginx-waf/module/zlib-1.2.11 --with-openssl=/data/server/nginx-waf/module/openssl-1.1.0h --add-module=/data/server/nginx-waf/module/lua-nginx-module-0.10.12 --add-module=/data/server/nginx-waf/module/ngx_devel_kit-0.2.19 --add-module=/data/server/nginx-waf/module/nginx-sticky-module-1.2.5 --add-module=/data/server/nginx-waf/module/echo-nginx-module-0.61 --add-module=/data/server/nginx-waf/module/ngx_cache_purge-2.3 --add-module=/data/server/nginx-waf/module/ngx_http_lower_upper_case --add-module=/data/server/nginx-waf/module/ModSecurity-nginx 以上是整合了luajit以及nginx-lua-module模块,添加了openwaf的配置后报错: # /data/server/nginx-1.14/sbin/nginx -t nginx: the configuration file /data/server/nginx-1.14/conf/nginx.conf syntax is ok nginx: [error] init_by_lua_file error: /opt/OpenWAF/app/twaf_init.lua:3: module 'resty.core' not found: no field package.preload['resty.core'] no file '/opt/OpenWAF/resty/core.lua' no file './resty/core.lua' no file '/usr/local/luajit/share/luajit-2.0.5/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core/init.lua' no file '/usr/local/luajit/share/lua/5.1/resty/core.lua' no file '/usr/local/luajit/share/lua/5.1/resty/core/init.lua' no file '/opt/OpenWAF/lib/resty/resty/core.so' no file './resty/core.so' no file '/usr/local/lib/lua/5.1/resty/core.so' no file '/usr/local/luajit/lib/lua/5.1/resty/core.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file '/opt/OpenWAF/lib/resty/resty.so' no file './resty.so' no file '/usr/local/lib/lua/5.1/resty.so' no file '/usr/local/luajit/lib/lua/5.1/resty.so' no file '/usr/local/lib/lua/5.1/loadall.so' stack traceback: [C]: in function 'require' /opt/OpenWAF/app/twaf_init.lua:3: in main chunk nginx: configuration file /data/server/nginx-1.14/conf/nginx.conf test failed

gitboy123 avatar May 18 '18 06:05 gitboy123

建议使用 OpenResty

linsir avatar May 18 '18 07:05 linsir

由于某些因素,公司不会使用OpenResty,一直都是原生的nginx,为了跟nginx官网保持一致的更新速度,现在都使用nginx-1.14了,我那个问题是啥原因?找不到的那些模块在oepnwaf安装后确实没有,很无奈。 建议给出一个原生nginx的配置使用教程,因为很多公司不用OpenResty

gitboy123 avatar May 18 '18 07:05 gitboy123

很抱歉,我并未用原生 nginx 搭建过 OpenWAF,都是基于OpenResty 运行的。 不过我可以提供协助,只希望搭建成功后,帮忙将搭建过程整理成文档,一起为开源做出点贡献

miracleqi avatar May 18 '18 10:05 miracleqi

/data/server/nginx-1.14/sbin/nginx -t

nginx: the configuration file /data/server/nginx-1.14/conf/nginx.conf syntax is ok nginx: [error] init_by_lua_file error: /opt/OpenWAF/lib/twaf/twaf_conf.lua:66: Expected value but found invalid number at character 99 stack traceback: [C]: in function 'decode' /opt/OpenWAF/lib/twaf/twaf_conf.lua:66: in function '_merge_table' /opt/OpenWAF/lib/twaf/twaf_conf.lua:82: in function 'load_access_rule' /opt/OpenWAF/app/twaf_init.lua:9: in main chunk nginx: configuration file /data/server/nginx-1.14/conf/nginx.conf test failed 弄了半天,还是有问题

gitboy123 avatar May 21 '18 05:05 gitboy123

/data/server/nginx-1.14/sbin/nginx -t

nginx: the configuration file /data/server/nginx-1.14/conf/nginx.conf syntax is ok nginx: [error] init_by_lua_file error: /opt/OpenWAF/lib/twaf/twaf_conf.lua:66: Expected value but found invalid number at character 99 stack traceback: [C]: in function 'decode' /opt/OpenWAF/lib/twaf/twaf_conf.lua:66: in function '_merge_table' /opt/OpenWAF/lib/twaf/twaf_conf.lua:82: in function 'load_access_rule' /opt/OpenWAF/app/twaf_init.lua:9: in main chunk nginx: configuration file /data/server/nginx-1.14/conf/nginx.conf test failed 弄了半天,还是有问题 请问现在解决了吗

V1og avatar Oct 22 '19 13:10 V1og

"Expected value but found invalid number at character 99" 这类问题是 json 格式错误导致的

miracleqi avatar Oct 23 '19 01:10 miracleqi

再结合 'load_access_rule' ,说明是 twaf_access_rule.json 的 json 格式错误

miracleqi avatar Oct 23 '19 01:10 miracleqi

init_by_lua_file error: /opt/OpenWAF/lib/twaf/twaf_conf.lua:11: module 'geoip.country' not found 但是安装GeoIP-devel,如何解决

wss2731 avatar Oct 11 '23 00:10 wss2731