bukaleyang / zhongkui-waf

WAF based on lua-nginx-module.
Apache License 2.0
165 stars 39 forks source link

无法启动nginx #12

Closed zihunyu closed 1 year ago

zihunyu commented 1 year ago

[root@VM-4-7-centos lib]# /usr/local/openresty/nginx/sbin/nginx nginx: [error] init_by_lua_file error: ...local/openresty/nginx/conf/zhongkui-waf/lib/redisCli.lua:13: attempt to index local 'config' (a boolean value) stack traceback: ...local/openresty/nginx/conf/zhongkui-waf/lib/redisCli.lua:13: in main chunk [C]: in function 'require' /usr/local/openresty/nginx/conf/zhongkui-waf/lib/lib.lua:2: in main chunk [C]: in function 'require' /usr/local/openresty/nginx/conf/zhongkui-waf/init.lua:2: in main chunk

启动报错

我在配置文件对应redis配置是 redis = "off",

zihunyu commented 1 year ago

[root@VM-4-7-centos zhongkui-waf]# /usr/local/openresty/nginx/sbin/nginx -V nginx version: openresty/1.21.4.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.21 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.11 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module 这是我的openresty的版本以及编译的依赖

zihunyu commented 1 year ago

[root@VM-4-7-centos zhongkui-waf]# /usr/local/openresty/nginx/sbin/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@VM-4-7-centos zhongkui-waf]# [root@VM-4-7-centos zhongkui-waf]# [root@VM-4-7-centos zhongkui-waf]# [root@VM-4-7-centos zhongkui-waf]# [root@VM-4-7-centos zhongkui-waf]# [root@VM-4-7-centos zhongkui-waf]# [root@VM-4-7-centos zhongkui-waf]# /usr/local/openresty/nginx/sbin/nginx nginx: [error] init_by_lua_file error: ...local/openresty/nginx/conf/zhongkui-waf/lib/redisCli.lua:13: attempt to index local 'config' (a boolean value) stack traceback: ...local/openresty/nginx/conf/zhongkui-waf/lib/redisCli.lua:13: in main chunk [C]: in function 'require' /usr/local/openresty/nginx/conf/zhongkui-waf/lib/lib.lua:2: in main chunk [C]: in function 'require' /usr/local/openresty/nginx/conf/zhongkui-waf/init.lua:2: in main chunk 检测配置文件的时候是没问题的 但是启动就报错了

bukaleyang commented 1 year ago

这个版本的OpenResty是没有问题的,我自己用的也是这个版本。贴一下你的配置文件,config.lua后半部分,即redis那部分。还有nginx配置中防火墙相关的部分配置。

zihunyu commented 1 year ago

这个版本的OpenResty是没有问题的,我自己用的也是这个版本。贴下你的配置文件,config.lua后半部分,即redis那部分。还有nginx配置中防火墙相关的部分配置。

config.lua -- 敏感数据脱敏 sensitive_data_filtering = "off",

-- Redis支持,打开后请求频率统计及ip黑名单将从Redis中存取
redis = "off",
redis_host = "127.0.0.0",
redis_port = "6377",
redis_passwd = "acb12345a6",
redis_ssl = false,
redis_pool_size = "10",
-- Respectively sets the connect, send, and read timeout thresholds (in ms)
redis_timeouts = "1000,1000,1000",

-- 是否重定向
redirect = "on",
-- 非法请求将重定向的html
redirect_html = "/usr/local/openresty/nginx/conf/zhongkui-waf/redirect.html",

-- 流量监控页面
dashboard = "off",
dashboard_html = "/usr/local/openresty/nginx/conf/zhongkui-waf/dashboard/dashboard.html"

}

function _M.get(option) return config[option] end -- Returns true if the config option is "on",otherwise false function _M.isOptionOn(option) return config[option] == "on" and true or false end

return _M

nginx.conf lua_shared_dict dict_cclimit 10m; lua_shared_dict dict_accesstoken 10m; lua_shared_dict dict_blackip 10m; lua_shared_dict dict_locks 100k; lua_shared_dict dict_config 5m; lua_shared_dict dict_config_rules_hits 5m; lua_shared_dict dict_req_count 5m; default_type application/octet-stream; lua_package_path "/usr/local/openresty/lualib/?.lua;/usr/local/openresty/nginx/conf/zhongkui-waf/?.lua;/usr/local/openresty/nginx/conf/zhongkui-waf/lib/?.lua;"; lua_shared_dict limit 10m; init_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/init.lua; init_worker_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/init_worker.lua; access_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/waf.lua; body_filter_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/body_filter.lua; header_filter_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/header_filter.lua; log_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/dashboard/count_traffic.lua;

bukaleyang commented 1 year ago

这个版本的OpenResty是没有问题的,我自己用的也是这个版本。贴下你的配置文件,config.lua后半部分,即redis那部分。还有nginx配置中防火墙相关的部分配置。

config.lua -- 敏感数据脱敏 sensitive_data_filtering = "off",

-- Redis支持,打开后请求频率统计及ip黑名单将从Redis中存取
redis = "off",
redis_host = "127.0.0.0",
redis_port = "6377",
redis_passwd = "abc1234a56",
redis_ssl = false,
redis_pool_size = "10",
-- Respectively sets the connect, send, and read timeout thresholds (in ms)
redis_timeouts = "1000,1000,1000",

-- 是否重定向
redirect = "on",
-- 非法请求将重定向的html
redirect_html = "/usr/local/openresty/nginx/conf/zhongkui-waf/redirect.html",

-- 流量监控页面
dashboard = "off",
dashboard_html = "/usr/local/openresty/nginx/conf/zhongkui-waf/dashboard/dashboard.html"

}

function _M.get(option) return config[option] end -- Returns true if the config option is "on",otherwise false function _M.isOptionOn(option) return config[option] == "on" and true or false end

return _M

nginx.conf lua_shared_dict dict_cclimit 10m; lua_shared_dict dict_accesstoken 10m; lua_shared_dict dict_blackip 10m; lua_shared_dict dict_locks 100k; lua_shared_dict dict_config 5m; lua_shared_dict dict_config_rules_hits 5m; lua_shared_dict dict_req_count 5m; default_type application/octet-stream; lua_package_path "/usr/local/openresty/lualib/?.lua;/usr/local/openresty/nginx/conf/zhongkui-waf/?.lua;/usr/local/openresty/nginx/conf/zhongkui-waf/lib/?.lua;"; lua_shared_dict limit 10m; init_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/init.lua; init_worker_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/init_worker.lua; access_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/waf.lua; body_filter_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/body_filter.lua; header_filter_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/header_filter.lua; log_by_lua_file /usr/local/openresty/nginx/conf/zhongkui-waf/dashboard/count_traffic.lua;

你的配置文件看上去是没有问题的,这就有点奇怪。 你把lua_package_path "/usr/local/openresty/lualib/?.lua;/usr/local/openresty/nginx/conf/zhongkui-waf/?.lua;/usr/local/openresty/nginx/conf/zhongkui-waf/lib/?.lua;"; 改成 lua_package_path "/usr/local/openresty/nginx/conf/zhongkui-waf/?.lua;/usr/local/openresty/nginx/conf/zhongkui-waf/lib/?.lua;;"; 试试,注意后面是两个分号。另外确保你修改后的config.lua文件是utf-8格式。

我修改了一下 lua_package_path 发现可以了

感谢感谢!!!

我修改了一下 lua_package_path 发现可以了

感谢感谢!!!

zihunyu commented 1 year ago

我修改了一下 lua_package_path 发现可以了

感谢感谢!!!

bukaleyang commented 1 year ago

你的Redis配置在这里贴过了,最好改下密码什么的。

zihunyu commented 1 year ago

你的Redis配置在这里贴过了,最好改下密码什么的。

好的 谢谢提醒 纯内网测试环境的地址的redis

bukaleyang commented 1 year ago

你甚至都不愿意点个star!!!

zihunyu commented 1 year ago

你甚至都不愿意点个star!!!

大佬 现在点了 现在点了 哈哈哈