mirror_request_body
The 'mirror_request_body' directive controls whether to mirror the request body in NGINX.
Description
The 'mirror_request_body' directive enables or disables the mirroring of request bodies in NGINX configuration. When set to 'on', it allows the request body received in the current request to be sent in a new mirrored request to an upstream server defined by the 'mirror' directive. This functionality is particularly useful for debugging purposes or when it is critical to retain the original request while performing some non-intrusive operations on it. Mirroring the request body can impact performance because it requires additional memory for buffering and network overhead for transmitting the body to the upstream server.
Config Example
location /api {
mirror_request_body on;
mirror /mirror_endpoint;
}Ensure that mirroring does not lead to unintended request processing or performance degradation.
Be cautious of large request bodies, as they can lead to increased memory usage due to buffering.
The mirrored request body can introduce delays in handling the original request if not managed properly.