nginx config_error ai_generated true

client intended to send too large body: 1048577 bytes exceeds client_body_buffer_size

ID: nginx/client-body-buffer-size-exceeded

Also available as: JSON · Markdown · 中文
90%Fix Rate
84%Confidence
1Evidence
2023-09-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
nginx 1.18.0 active
nginx 1.20.2 active
nginx 1.24.0 active

Root Cause

The request body size exceeds the client_body_buffer_size directive, causing nginx to reject or buffer to disk; if client_body_max_size is also exceeded, nginx returns 413.

generic

中文

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

Official Documentation

https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size

Workarounds

  1. 90% success 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.
    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. 95% success 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;
    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. 85% success For specific endpoints, set a higher buffer size only for that location: location /upload { client_body_buffer_size 4m; client_body_max_size 100m; }
    For specific endpoints, set a higher buffer size only for that location:
    location /upload {
        client_body_buffer_size 4m;
        client_body_max_size 100m;
    }

中文步骤

  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;
    }

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Setting to 0 disables buffering entirely, which may cause nginx to use temporary files inefficiently and slow down.

  2. 70% fail

    The error specifically mentions client_body_buffer_size; increasing max size alone does not resolve the buffer limit warning.

  3. 60% fail

    This may cause nginx to forward the body immediately but can lead to upstream timeouts or resource issues.