Mitigating Ingress-Nginx Warnings: Client Request Body Buffered to Temporary File in RKE2
Article Number: 000022084
Environment
An RKE2 cluster using the bundled rke2-ingress-nginx controller.
Situation
The rke2-ingress-nginx-controller pods are continuously emitting warning logs indicating that the client request body is being buffered to a temporary file.
An example of the logged warning is:
[warn]: *16039 a client request body is buffered to a temporary file /tmp/nginx/client-body/0000019201, client: 10.x.x.x
This warning persists even when the maximum client body size (client_max_body_size), configured via proxy-body-size, has been set to a large value (e.g., 1024m).
Cause
The warning a client request body is buffered to a temporary file occurs because the incoming request body size exceeds the allocated in-memory buffer (client_body_buffer_size), forcing NGINX to write the excess data to a temporary file on disk.
The distinction is critical:
1. client_max_body_size (set via proxy-body-size) limits the total request size (preventing 413 errors).
2. client_body_buffer_size (set via client-body-buffer-size) limits the amount NGINX holds in memory for the request body before writing to disk.
If the warning persists despite a large proxy-body-size, the client-body-buffer-size needs to be increased to prevent disk I/O and performance overhead
Resolution
To resolve this issue, you must increase the maximum size of the in-memory buffer using the client-body-buffer-size configuration key, which is defined in the NGINX configuration map and managed in RKE2 via a HelmChartConfig resource.
Configure Client Body Buffer Size via HelmChartConfig (RKE2)
To configure NGINX parameters for the bundled rke2-ingress-nginx controller, you create or modify a HelmChartConfig resource in the kube-system namespace. These configurations are passed through the controller.config map.
In the example below, both the maximum allowed size (proxy-body-size) and the in-memory buffer size (client-body-buffer-size) are configured to a large value (e.g., 5MB, but adjust based on your workload needs):
1. Create or modify the HelmChartConfig resource for rke2-ingress-nginx:
2. Applying the Configuration:
◦ Standalone RKE2 cluster: Save this manifest (e.g., /var/lib/rancher/rke2/server/manifests/rke2-ingress-nginx-config.yaml) and restart the rke2-server service.
◦ Rancher-provisioned RKE2 cluster: Apply this YAML in the Additional Manifests section when editing the cluster configuration.
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: rke2-ingress-nginx
namespace: kube-system
spec:
valuesContent: |-
controller:
config:
# Configures client_max_body_size (e.g., to prevent 413 errors)
proxy-body-size: "5m"
# Configures client_body_buffer_size (e.g., to prevent disk buffering warnings)
client-body-buffer-size: "5m"
If the warning persists, ensure the new configurations have been correctly applied and loaded by the NGINX process.
Confirm that the NGINX configuration has been reloaded, sometimes requiring a manual restart of the rke2-ingress-nginx-controller DaemonSet.