Skip to content

How to Configure Nginx Proxy Buffering

DodaTech Updated 2026-06-24 1 min read

Proxy buffering controls how Nginx handles backend responses. Disabling it for streaming ensures real-time delivery. This guide walks through the specific troubleshooting steps to diagnose and resolve proxy buffering issues.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

proxy_buffering on (may cause delays for streaming)

Wrong: Buffering enabled for streaming endpoints

location /stream {\n    proxy_buffering off;\n    proxy_cache off;\n    proxy_set_header X-Accel-Buffering no;\n}

Right: Disabling buffering for streaming/real-time traffic

Output

Proxy buffering configure for /stream:\n  Buffering: off\n  Cache: off\n  X-Accel-Buffering: no

Prevention

To avoid future issues, follow these best practices:

  • Disable proxy_buffering for streaming, Server-Sent Events, and WebSocket endpoints
  • Enable proxy_buffering for API responses to improve backend performance
  • Tune proxy_buffer_size and proxy_buffers for response headers
  • Use proxy_max_temp_file_size to control disk buffering
  • Monitor buffer usage with $upstream_response_length and $upstream_response_time

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with proxy buffering

  1. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  2. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  3. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks

These mistakes appear frequently in real-world NGINX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

When should I disable proxy buffering?|||For streaming, real-time applications, large file downloads, and Server-Sent Events where immediate delivery is critical.
How does proxy buffering affect performance? Buffering allows Nginx to read the full response from the backend before sending it to the client, reducing load on slow clients.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro