Skip to content

Instantly share code, notes, and snippets.

@ecarreras
Created January 18, 2025 15:39
Show Gist options
  • Save ecarreras/ba4adc5efbd108ddec0ff501617585c1 to your computer and use it in GitHub Desktop.
Save ecarreras/ba4adc5efbd108ddec0ff501617585c1 to your computer and use it in GitHub Desktop.
upstream sse_backend {
server localhost:38068;
}
server {
# ....
location /api/stream {
proxy_pass http://sse_backend/stream;
proxy_buffering off;
proxy_cache off;
chunked_transfer_encoding off;
add_header Content-Type text/event-stream;
add_header Cache-Control no-cache;
proxy_read_timeout 86400;
proxy_send_timeout 86400;
keepalive_timeout 0;
error_page 502 =200 @fallback_sse;
}
location @fallback_sse {
default_type text/event-stream;
add_header Cache-Control no-cache;
return 200;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment