When introducing a Server-Sent Events (SSE) log tailing endpoint, browser clients reported that log events arrived in sporadic batches of 4KB chunks rather than streaming continuously line by line.
location /api/v1/stream {
proxy_pass http://upstream_backend;
# Disable proxy buffering specifically for SSE connections:
proxy_buffering off;
proxy_cache off;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
}
By default Nginx buffers upstream responses until proxy_buffer_size (usually 4KB or 8KB) is filled. Turning off buffering for the streaming path allows PHP output flushes (ob_flush(); flush();) to reach the client with sub-millisecond delivery.