Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gitboy123 opened this issue May 18, 2018 · 8 comments
Open

Comments

@gitboy123
Copy link

gitboy123 commented May 18, 2018

/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

@linsir
Copy link
Contributor

linsir commented May 18, 2018

建议使用 OpenResty

@gitboy123
Copy link
Author

gitboy123 commented May 18, 2018

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

@miracleqi
Copy link
Collaborator

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

@gitboy123
Copy link
Author

/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
Copy link

V1og commented Oct 22, 2019

/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
弄了半天,还是有问题
请问现在解决了吗

@miracleqi
Copy link
Collaborator

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

@miracleqi
Copy link
Collaborator

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

@wss2731
Copy link

wss2731 commented Oct 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants