# 客户端请求体大小超过缓冲区限制

- **ID:** `nginx/client-body-buffer-size-exceeded`
- **领域:** nginx
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

请求体大小超过client_body_buffer_size指令限制，导致nginx拒绝或缓冲到磁盘；如果同时超过client_body_max_size，nginx返回413。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| nginx 1.18.0 | active | — | — |
| nginx 1.20.2 | active | — | — |
| nginx 1.24.0 | active | — | — |

## 解决方案

1. ```
   Increase client_body_buffer_size in http, server, or location block:
client_body_buffer_size 2m;
This allows larger bodies to be buffered in memory.
   ```
2. ```
   If the body size is expected to be large, also increase client_body_max_size:
client_body_max_size 10m;
client_body_buffer_size 2m;
   ```
3. ```
   For specific endpoints, set a higher buffer size only for that location:
location /upload {
    client_body_buffer_size 4m;
    client_body_max_size 100m;
}
   ```

## 无效尝试

- **** — Setting to 0 disables buffering entirely, which may cause nginx to use temporary files inefficiently and slow down. (50% 失败率)
- **** — The error specifically mentions client_body_buffer_size; increasing max size alone does not resolve the buffer limit warning. (70% 失败率)
- **** — This may cause nginx to forward the body immediately but can lead to upstream timeouts or resource issues. (60% 失败率)
