Caddy 2.8 vs Nginx vs Cloudflare Tunnel for AI Webhooks: Measured TTFB, Streaming SSE & Why I Run Two Together
Direct Nginx or Caddy on a datacenter VPS delivers 1.5 ms origin render with zero third-party hop, while Cloudflare Tunnel (`cloudflared`, 39 MB RSS) adds ~50–150 ms edge hop overhead in exchange for zero open inbound ports and instant CGNAT bypass. For VPS-hosted n8n/OpenClaw, use Caddy 2.8 with `flush_interval -1`; for home Mac mini / N100 boxes—or hiding your origin VPS IP behind edge DDoS protection—pair local Nginx/Caddy with `cloudflared`.
1. The Reverse-Proxy Debate Nobody Benchmarks Properly
Most self-hosting tutorials treat Caddy, Nginx, and Cloudflare Tunnel as mutually exclusive religions. In production AI stacks—where n8n receives Stripe/Telegram webhooks, OpenClaw streams token-by-token responses over Server-Sent Events (SSE), and voice agents need sub-900 ms turns—choosing the wrong proxy or forgetting one buffering flag silently breaks streaming.
On our live node (`192.227.155.161`), we measured local Nginx origin TTFB at 1.5 ms (`0.001506s`) and full HTTPS delivery through `cloudflared` at 150.4 ms (`0.150397s`) with `cloudflared` consuming 40,064 KB (39.1 MB) RSS. That ~149 ms difference is completely invisible for static web pages and async webhooks, yet noticeable if you chain three synchronous voice-agent hops across continents.
| Proxy Layer | Measured RSS | Auto HTTPS | Streaming SSE Trap | Best Production Role |
|---|---|---|---|---|
| Caddy 2.8 | ~32–45 MB | Zero-config ACME | Add flush_interval -1 | Default all-in-one VPS proxy for n8n/OpenClaw |
| Nginx | ~18–26 MB | Needs Certbot/CF | Set proxy_buffering off | High-throughput static + /go/* click logging |
| Cloudflare Tunnel | 39.1 MB (measured) | Edge TLS included | 100s HTTP timeout cap on Free | Home N100/Mac mini CGNAT bypass + zero open ports |
2. The 100-Second Cloudflare Timeout Trap on Long AI Workflows
Here is the single biggest surprise engineers hit after putting n8n behind Cloudflare Tunnel or Orange-Cloud proxy: Cloudflare Free and Pro plans enforce a strict **100-second HTTP read timeout** (Error 524). If a synchronous webhook triggers a deep research AI agent or scrapes 20 URLs before replying, Cloudflare severs the connection at second 100—even though n8n keeps running in the background.
The architectural fix is never "abandon Cloudflare." It is making long-running n8n webhooks respond immediately (`202 Accepted` using the "Respond to Webhook" node) and push final results asynchronously via callback URL, Slack, or Telegram. For synchronous streaming LLM responses under 100 seconds, disable proxy buffering (`flush_interval -1` in Caddy; `proxy_buffering off;` in Nginx) so tokens flush immediately instead of stalling until completion.
3. Exact Zero-Buffering Configs for Streaming AI Agents
Whether you choose Caddy 2.8 on a $48/yr VPS or Nginx behind a home Cloudflare Tunnel, copy the exact streaming block below so SSE tokens and ElevenLabs audio chunks never buffer in proxy RAM:
# Option A: Caddy 2.8 (recommended for VPS n8n / OpenClaw)
agent.yourdomain.com {
encode zstd gzip
reverse_proxy n8n:5678 {
flush_interval -1
transport http {
read_timeout 120s
}
}
}
# Option B: Nginx behind Cloudflare Tunnel (127.0.0.1 loopback only)
location / {
proxy_pass http://127.0.0.1:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
proxy_cache off;
chunked_transfer_encoding on;
}