nginx
config_error
ai_generated
true
客户端试图发送过大的请求体:请求体大小超过 client_body_buffer_size
client intended to send too large body: body size exceeds client_body_buffer_size
ID: nginx/client-body-buffer-overflow
90%修复率
85%置信度
1证据数
2024-01-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| nginx 1.24.0 | active | — | — | — |
| nginx 1.22.1 | active | — | — | — |
| nginx 1.20.2 | active | — | — | — |
根因分析
Nginx 在请求体超过 client_body_buffer_size 时将其缓冲到临时文件,但如果请求体过大且 client_max_body_size 未正确设置,连接会被拒绝。
English
Nginx buffers the request body to a temporary file when it exceeds client_body_buffer_size, but if the body is too large and client_max_body_size is not properly set, the connection is rejected.
官方文档
https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size解决方案
-
Increase client_max_body_size in http, server, or location block to allow larger bodies: `client_max_body_size 50M;`
-
Ensure client_body_buffer_size is set appropriately (e.g., 128k) and that the system has enough disk space for temporary files in the path defined by client_body_temp_path.
-
Check the actual body size in logs and set client_max_body_size accordingly. For file uploads, ensure the frontend sends the correct Content-Length header.
无效尝试
常见但无效的做法:
-
70% 失败
client_body_buffer_size only controls in-memory buffering; client_max_body_size is the actual limit.
-
50% 失败
This can cause upstream servers to receive partial data and may break applications that expect full body.
-
90% 失败
proxy_buffer_size is for response headers, not request bodies.