新版本openresty无法使用1Panel高级功能的WAF

openwrt系统,linkease/istorepanel:latest镜像启动的1Panel。
1panel/openresty:1.27.1.2-0-1-focal镜像在不修改配置文件的情况下启动容器会报错:

 [warn] 1#1: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /usr/local/openresty/nginx/conf/conf.d/00.default.conf:8
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /usr/local/openresty/nginx/conf/conf.d/00.default.conf:8
 [notice] 1#1: [lua] config.lua:136: ini_waf_info(): Load 1Panel WAF Version:1.0.0
nginx: [error] [lua] file.lua:191: ensure_dir_exists(): Failed to create directory:No such file or directory
nginx: [error] [lua] file.lua:191: ensure_dir_exists(): Failed to create directory:No such file or directory
 [error] 1#1: [lua] file.lua:191: ensure_dir_exists(): Failed to create directory:No such file or directory
 [error] 1#1: [lua] file.lua:191: ensure_dir_exists(): Failed to create directory:No such file or directory
 [error] 1#1: init_by_lua_file error: ./config.lua:183: attempt to index field 'log' (a nil value)
stack traceback:
	./config.lua:183: in function 'init_global_config'
	./config.lua:252: in function 'load_config_file'
	./init.lua:6: in main chunk
nginx: [error] init_by_lua_file error: ./config.lua:183: attempt to index field 'log' (a nil value)
stack traceback:
	./config.lua:183: in function 'init_global_config'
	./config.lua:252: in function 'load_config_file'
	./init.lua:6: in main chunk

1panel/openresty:1.25.3.2-0-1-focal镜像在不修改配置文件的情况下容器可以正常启动,但是开启WAF后网站报错500 Internal Server Error,关闭WAF后网站正常运行。容器日志如下:

 [warn] 1#1: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /usr/local/openresty/nginx/conf/conf.d/00.default.conf:8
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /usr/local/openresty/nginx/conf/conf.d/00.default.conf:8
 [notice] 1#1: [lua] config.lua:143: ini_waf_info(): Load 1Panel WAF Version:1.0.0
 [error] 1#1: [lua] file.lua:168: ensure_dir_exists(): Failed to create directory:No such file or directory
 [error] 1#1: [lua] file.lua:168: ensure_dir_exists(): Failed to create directory:No such file or directory
nginx: [error] [lua] file.lua:168: ensure_dir_exists(): Failed to create directory:No such file or directory
nginx: [error] [lua] file.lua:168: ensure_dir_exists(): Failed to create directory:No such file or directory
 [error] 1#1: [lua] file.lua:17: read_rule(): Failed to open file /usr/local/openresty/1pwaf/data/rules/urlcc.json: No such file or directory
nginx: [error] [lua] file.lua:17: read_rule(): Failed to open file /usr/local/openresty/1pwaf/data/rules/urlcc.json: No such file or directory
nginx: [error] [lua] db_init.lua:41: init_db_config(): failed to open db /usr/local/openresty/1pwaf/data/db/global/location.db
 [error] 1#1: [lua] db_init.lua:41: init_db_config(): failed to open db /usr/local/openresty/1pwaf/data/db/global/location.db
 [notice] 1#1: using the "epoll" event method
 [notice] 1#1: openresty/1.25.3.2
 [notice] 1#1: built by gcc 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2) 
 [notice] 1#1: OS: Linux 6.12.21
 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
 [notice] 1#1: start worker processes
 [notice] 1#1: start worker process 9
 [notice] 1#1: start worker process 10
 [notice] 1#1: start worker process 11
 [notice] 1#1: start worker process 12
 [notice] 1#1: signal 1 (SIGHUP) received from 19, reconfiguring
 [notice] 1#1: reconfiguring
 [warn] 1#1: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /usr/local/openresty/nginx/conf/conf.d/00.default.conf:8
 [notice] 1#1: [lua] config.lua:143: ini_waf_info(): Load 1Panel WAF Version:1.0.0
 [error] 1#1: [lua] file.lua:17: read_rule(): Failed to open file /usr/local/openresty/1pwaf/data/rules/urlcc.json: No such file or directory
 [notice] 1#1: using the "epoll" event method
 [notice] 1#1: start worker processes
 [notice] 1#1: start worker process 31
 [notice] 1#1: start worker process 32
 [notice] 1#1: start worker process 33
 [notice] 1#1: start worker process 34
 [notice] 9#9: gracefully shutting down

1panel/openresty:1.21.4.3-3-3-focal镜像的容器可以正常启动,网站和WAF可以正常运行。容器日志:

 [notice] 1#1: [lua] config.lua:126: ini_waf_info(): Load 1Panel WAF Version:1.0.0
nginx: [error] [lua] file.lua:129: ensure_dir_exists(): Failed to create directory:No such file or directory
 [error] 1#1: [lua] file.lua:129: ensure_dir_exists(): Failed to create directory:No such file or directory
nginx: [error] [lua] db.lua:126: init(): init waf_stat status0
 [error] 1#1: [lua] db.lua:126: init(): init waf_stat status0
 [error] 1#1: [lua] db.lua:160: init(): init req_logs status0
nginx: [error] [lua] db.lua:160: init(): init req_logs status0
 [error] 1#1: [lua] db.lua:178: init(): init block_ip status0
nginx: [error] [lua] db.lua:178: init(): init block_ip status0
 [notice] 1#1: using the "epoll" event method
 [notice] 1#1: openresty/1.21.4.3
 [notice] 1#1: built by gcc 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2) 
 [notice] 1#1: OS: Linux 6.12.21
 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
 [notice] 1#1: start worker processes
 [notice] 1#1: start worker process 9
 [notice] 1#1: start worker process 10
 [notice] 1#1: start worker process 11
 [notice] 1#1: start worker process 12
 [notice] 1#1: signal 1 (SIGHUP) received from 19, reconfiguring
 [notice] 1#1: reconfiguring
 [notice] 1#1: [lua] config.lua:126: ini_waf_info(): Load 1Panel WAF Version:1.0.0
 [error] 1#1: [lua] db.lua:264: init_website_monitor(): init default.wm26.top site_stat table status0
 [notice] 1#1: using the "epoll" event method
 [notice] 1#1: start worker processes
 [notice] 1#1: start worker process 25
 [notice] 1#1: start worker process 26
 [notice] 1#1: start worker process 27
 [notice] 1#1: start worker process 28
 [notice] 9#9: gracefully shutting down

能否让1.27.1.2-0-1-focal及更新版本的1panel/openresty支持1Panel面板的WAF功能?
新版openresty修复了许多错误和漏洞,更想用新版。1Panel的WAF也足够满足我的需求,不打算再折腾其他WAF。

不好意思 我们当前还没有适配 openwrt

这个错误会发生是因为系统是openwrt吗?

也有可能是文件的问题 openwrt 现在无法自动安装应用商店的应用
需要把挂载的目录改为全路径

我在一台VMware的X86虚拟机里试了一下,iStoreOS 22.03.7 2024122712系统。
使用命令curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && bash quick_start.sh安装1Panel v1.10.29-lts。安装至/opt,镜像加速地址https://docker.xuanyuan.me,其余选项默认。
安装1panel/openresty:1.27.1.2-0-1-focal的compose文件:

services:
    openresty:
        container_name: ${CONTAINER_NAME}
        image: 1panel/openresty:1.27.1.2-0-1-focal
        labels:
            com.centurylinklabs.watchtower.enable: false
            createdBy: Apps
        network_mode: host
        restart: always
        volumes:
            - ./conf:/usr/local/openresty/nginx/conf
            - ./log:/var/log/nginx
            - ./www:/www
            - ./root:/usr/share/nginx/html
            - ./1pwaf/data:/usr/local/openresty/1pwaf/data
            - /etc/localtime:/etc/localtime

安装完成后还是报同样的错误:

nginx: [error] init_by_lua_file error: ./config.lua:183: attempt to index field 'log' (a nil value)
stack traceback:
	./config.lua:183: in function 'init_global_config'
	./config.lua:252: in function 'load_config_file'
	./init.lua:6: in main chunk

所以应该不是1Panel容器没有挂载相关文件导致报错。

希望新版本的1panel/openresty镜像能做相关的适配,因为老版本(如1.21.4.3-3-3-focal)的1panel/openresty镜像是可以和1Panel v1.10.29-lts的WAF正常搭配使用的。

init_by_lua_file error: ./config.lua:183: attempt to index field 'log' (a nil value)

能提供报错的这里具体是在读取哪个位置的log吗?我好开放给容器
1Panel版本是 v1.10.29-lts

你这个版本是给 v2 用的 我没注意

没懂。
是说v1版本的1Panel的WAF最高只能支持到1panel/openresty:1.21.4.4-0-1-focal这个版本,以后更新的v2的1Panel的WAF才能支持1.25.3.2-0-1-focal、1.27.1.2-0-1-focal及更新的版本吗?
如果1Panel v1版本想使用1.27.1.2-0-1-focal的1panel/openresty只能在nginx.conf文件里把waf.conf那一行注释掉才能正常启动吗?

还是说只是1.27.1.2-0-1-focal的1panel/openresty镜像里config.lua这个文件用错版本了,更换正确的版本就可以解决这个报错?

如果是v1版本的1Panel的WAF最高只能支持到1panel/openresty:1.21.4.4-0-1-focal这个版本,那么1Panel的v2版本什么时候发布呢?v2发布后v1版本能不能无缝升级到v2版本呢?