NGINX CRITICAL BUFFERING CACHE PROXY

This commit is contained in:
DrMelone
2026-01-11 18:04:38 +01:00
parent 201fdaf102
commit e005a46a51
7 changed files with 98 additions and 0 deletions

View File

@@ -38,6 +38,30 @@ proxy_set_header Connection "upgrade";
:::
:::danger Critical: Disable Proxy Buffering for SSE Streaming
**This is the most common cause of garbled markdown and broken streaming responses.**
When Nginx's `proxy_buffering` is enabled (the default!), it re-chunks SSE streams arbitrarily. This breaks markdown tokens across chunk boundaries—for example, `**bold**` becomes `**` + `bold` + `**`—causing corrupted output with visible `##`, `**`, or missing words.
**You MUST include these directives in your Nginx location block:**
```nginx
# CRITICAL: Disable buffering for SSE streaming
proxy_buffering off;
proxy_cache off;
```
**Symptoms if you forget this:**
- Raw markdown tokens visible (`##`, `**`, `###`)
- Bold/heading markers appearing incorrectly
- Words or sections randomly missing from responses
- Streaming works perfectly when disabled, breaks when enabled
**Bonus:** Disabling buffering also makes streaming responses **significantly faster**, as content flows directly to the client without Nginx's buffering delay.
:::
Choose the method that best fits your deployment needs.
import Tabs from '@theme/Tabs';

View File

@@ -224,6 +224,7 @@ With the certificate saved in your `ssl` directory, you can now update the Nginx
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 10m;
proxy_buffering off;
proxy_cache off;
client_max_body_size 20M;
proxy_no_cache 1;
@@ -257,6 +258,7 @@ With the certificate saved in your `ssl` directory, you can now update the Nginx
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 10m;
proxy_buffering off;
proxy_cache off;
client_max_body_size 20M;
add_header Cache-Control "public, max-age=300, must-revalidate";

View File

@@ -79,6 +79,21 @@ Failure to do so will cause WebSocket connections to fail, even if you have enab
:::
:::danger Critical: Disable Proxy Buffering for Streaming
**This is the most common cause of garbled markdown and broken streaming responses.**
In Nginx Proxy Manager, go to your proxy host → **Advanced** tab → and add these directives to the **Custom Nginx Configuration** field:
```nginx
proxy_buffering off;
proxy_cache off;
```
Without this, Nginx re-chunks SSE streams, breaking markdown formatting (visible `##`, `**`, missing words). This also makes streaming responses significantly faster.
:::
:::tip Caching Best Practice
While Nginx Proxy Manager handles most configuration automatically, be aware that:

View File

@@ -36,6 +36,7 @@ Using self-signed certificates is suitable for development or internal use where
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
client_max_body_size 20M;
proxy_read_timeout 10m;
@@ -68,6 +69,7 @@ Using self-signed certificates is suitable for development or internal use where
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
client_max_body_size 20M;
proxy_read_timeout 10m;

View File

@@ -113,6 +113,7 @@ http {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
client_max_body_size 20M;
proxy_read_timeout 10m;
@@ -142,6 +143,7 @@ http {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
client_max_body_size 20M;
proxy_read_timeout 10m;