nginx
protocol_error
ai_generated
true
上游发送了无效的 Content-Encoding 头
upstream sent invalid content-encoding while reading response header from upstream
ID: nginx/upstream-sent-invalid-content-encoding
89%修复率
83%置信度
1证据数
2024-05-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| nginx/1.24.0 | active | — | — | — |
| nginx/1.22.1 | active | — | — | — |
根因分析
上游服务器返回了不受支持或格式错误的 Content-Encoding 头(例如 'gzip;q=1.0' 而非 'gzip'),导致 nginx 解压缩失败。
English
Upstream server returned a Content-Encoding header with an unsupported or malformed value (e.g., 'gzip;q=1.0' instead of 'gzip'), causing nginx to fail decompression.
官方文档
https://nginx.org/en/docs/http/ngx_http_proxy_module.html解决方案
-
Fix upstream server to return valid Content-Encoding (e.g., in PHP: header('Content-Encoding: gzip'); not 'gzip;q=1.0'). For Apache backend, ensure mod_deflate uses correct header. -
Add proxy_ignore_headers Content-Encoding; in nginx config to ignore upstream encoding and treat response as uncompressed. Example: location / { proxy_pass http://backend; proxy_ignore_headers Content-Encoding; } -
Set proxy_set_header Accept-Encoding identity; to request uncompressed content from upstream.
无效尝试
常见但无效的做法:
-
85% 失败
This only compresses responses from nginx to client, not upstream response handling.
-
70% 失败
This prevents upstream from sending compressed responses, but if upstream still sends Content-Encoding, the error persists.
-
80% 失败
The error is about header value validity, not size.