最近为了修复漏洞,把nginx升级到1.24.0,编译时报错:error: ‘ngx_http_headers_in_t’ has no member named ‘cookies’。
经查阅资料发现报错是编译nginx的lua模块有关,我使用的是lua-nginx-module-0.10.21。
❌ 问题原因
这个错误是由于nginx版本升级后,lua-nginx-module模块与新版本nginx的兼容性问题导致的。
✅ 解决办法
找到模块源码文件:lua-nginx-module-0.10.21/src/ngx_http_lua_headers_in.c
将以下代码:
offsetof(ngx_http_headers_in_t, cookies),
修改为:
offsetof(ngx_http_headers_in_t, cookie),
🔧 修复步骤
- 定位到lua-nginx-module源码目录
- 编辑文件
src/ngx_http_lua_headers_in.c
- 查找
cookies
并修改为cookie
- 重新编译nginx
重新编译就没有报错了,祝你好运!
💡 提示
这个问题主要是因为nginx内部结构体成员名称的变化,从复数形式改为单数形式。如果遇到类似的兼容性问题,可以查看nginx的源码变更日志来确认具体的修改内容。