mirror of
https://github.com/ADD-SP/ngx_waf.git
synced 2026-04-26 22:15:55 +03:00
[GH-ISSUE #68] 日志轮转时出错 #46
Labels
No labels
MacOS
Nginx
OpenResty
Tengine
bug
documentation
enhancement
needs-investigation
pull-request
question
stale
stale
stale
timeout
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ngx_waf#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @purplegrape on GitHub (Oct 9, 2021).
Original GitHub issue: https://github.com/ADD-SP/ngx_waf/issues/68
nginx 版本 1.20.1
ngx_waf 版本 6.1.5 (6.1.4也存在类似问题)
通过dmesg -T 命令发现,ngx_http_waf 模块有如下类似报错
[Sat Oct 9 03:20:15 2021] nginx[3355]: segfault at 18 ip 00007fa9f6493659 sp 00007ffe2a3c0600 error 4 in ngx_http_waf_module.so[7fa9f6453000+6b000]
开debug之后,error.log部分日志如下
2021/10/09 03:22:01 [debug] 3355#3355: *345447 ngx_waf_debug: The module context has been obtained.
2021/10/09 03:22:01 [debug] 3355#3355: *345447 ngx_waf_debug: The configuration of the module has been obtained.
2021/10/09 03:22:01 [notice] 25988#25988: signal 17 (SIGCHLD) received from 3355
2021/10/09 03:22:01 [alert] 25988#25988: worker process 3355 exited on signal 11
2021/10/09 03:22:01 [notice] 25988#25988: start worker process 4887
2021/10/09 03:22:01 [notice] 25988#25988: signal 29 (SIGIO) received
2021/10/09 03:22:01 [notice] 4887#4887: sched_setaffinity(): using cpu #2
2021/10/09 03:22:01 [debug] 4887#4887: *346468 ngx_waf_debug: The scheduler has been started.
2021/10/09 03:22:01 [debug] 4887#4887: *346468 ngx_waf_debug: The module context has been obtained.
2021/10/09 03:22:01 [debug] 4887#4887: *346468 ngx_waf_debug: The configuration of the module has been obtained.
此次问题大概发生在logrotate 时,其它时间也偶有触发,手动 logrotate -f /etc/logrotate.d/nginx 无法重现,请求大神分析。
@ADD-SP commented on GitHub (Oct 9, 2021):
检查一下 nginx 日志目录下是否有名为
core的文件。@purplegrape commented on GitHub (Oct 9, 2021):
没有
@ADD-SP commented on GitHub (Oct 9, 2021):
先完成链接内所示的前五步,然后等待错误出现,错误出现后按链接内所示的第七步开始完成后续的所有步骤。
https://github.com/ADD-SP/ngx_waf/issues/18#issuecomment-760785975
@purplegrape commented on GitHub (Oct 9, 2021):
补充一点,nginx和动态模块的二进制文件均是在centos7+gcc 4.8 下编译,实际运行环境为amaozn linux 2
在闲置服务器上运行正常,生产环境出现worker异常退出
@purplegrape commented on GitHub (Oct 12, 2021):
由于是生产环境,没敢大动作调试,经过摸索,将waf_mode 从STD 改为 STATIC ,worker异常退出已消失。
另外一个开发测试环境,流量小,异常一直未被触发,问题症结推测应该是某个动态逻辑或规则。
@ADD-SP commented on GitHub (Oct 12, 2021):
尝试设置
waf_mode STD !POST;,有可能是 v6.1.5 版本存在的一个读取 POST 请求的 Bug 导致的。如果按此设置后问题消失可以尝试升级到 v6.1.6。尝试设置
waf_mode STD !LIB-INJECTION-SQLI;,有可能是依赖库 libinjection 导致的。如果按此设置后问题消失则可以保持这个设置,即!LIB-INJECTION-SQLI。如果需要检测 SQL 注入建议升级到最新的 Current 版本,此版本集成了 ModSecurity,可以使用 ModSecurity CRS。虽然是废话,但是鉴于生产环境十分重要,升级后最好特别关注服务状态。
@purplegrape commented on GitHub (Oct 19, 2021):
与日志轮转无关,但暂时难以定位问题根源,上文临时方法确认有效,故关闭issue 。
@ADD-SP commented on GitHub (Oct 19, 2021):
是哪个临时方法有效?或许能借此推测根源。是否更新了模块版本?
@purplegrape commented on GitHub (Oct 20, 2021):
waf_mode STATIC;
waf_mode STD !LIB-INJECTION-SQLI;
以上临时方法在生产环境实测有效,可规避worker异常退出
PS:模块更新到了6.1.6
@ADD-SP commented on GitHub (Oct 20, 2021):
编译模块的时候是否添加了
gcc的-fstack-protector-strong参数?@purplegrape commented on GitHub (Oct 20, 2021):
使用rpmbuild 自动化编译,只是按照文档指示加了参数-std=gnu99
--with-cc-opt=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -std=gnu99
@ADD-SP commented on GitHub (Oct 26, 2021):
错误一时难以定位,暂时关闭,必要时再打开。