EventSource / Server-Sent Events through Nginx

Your Nginx config is correct, you just miss few lines.

Here is a “magic trio” making EventSource working through Nginx:

proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;

Place them into location section and it should work.

You may also need to add

proxy_buffering off;
proxy_cache off;

That’s not an official way of doing it.

I ended up with this by “trial and errors” + “googling” 🙂

Leave a Comment