proxy_pass_request_body

The `proxy_pass_request_body` directive controls whether the request body is passed to the proxied server in NGINX. — NGINX HTTP Core

proxy_pass_request_body
httpserverlocation
Синтаксисproxy_pass_request_body on | off;
По умолчаниюon
Контекстhttp, server, location
МодульNGINX HTTP Core
Аргументыflag

Описание

The `proxy_pass_request_body` directive is a boolean flag used in the context of http, server, and location blocks within the NGINX configuration. When this directive is set to "on", NGINX will send the request body to the proxied server when forwarding requests. This is particularly significant when handling POST requests or any request that contains a body, such as data uploads. If the directive is set to "off", the request body will not be sent to the upstream server, which may lead to unexpected behavior if the application relies on receiving the body. The directive allows fine-tuning of request handling in proxy situations, enabling optimizations for different backend applications. The absence of this directive defaults to "on", meaning that by default, the request body will be forwarded unless explicitly configured otherwise. This can be critical for applications expecting data to be processed in a proxied setup. Configuration of this directive is straightforward and does not require additional parameters beyond the flag to enable or disable the behavior. Overall, it aids in controlling the flow of request data, making it essential for proper functioning of web applications that rely on NGINX as a reverse proxy.

Пример конфига

location /api {
    proxy_pass http://backend;
    proxy_pass_request_body off;
}

For POST requests, ensure that `proxy_pass_request_body` is set to `on` if the backend needs the body.

Setting this directive to `off` may result in incomplete data processing on the proxied server.

Usage in the wrong context (like inside the server block) will lead to configuration errors.