Oct 18, 2016, 12:07

nginx-proxy configuration for server sent events and SSL

I've encountered issue with dropped SSE connection when deployed SSE based sinatra app with SSL certificates and nginx-proxy docker container.

First, create vhost.d directory on host and connect it to /etc/nginx/vhost.d in nginx-proxy container via volume. Create corresponding file to your VIRTUAL_HOST name, which will be included upon nginx startup. In my case that was SSE stream.it-premium.com.ua.

My /home/nexus/vhost.d/stream.it-premium.com.ua file is following

proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;

But it has still issues with dropped connection.
Finally I've updated app code with following headers:

response['Cache-control'] = 'no-cache'
response['X-Accel-Buffering'] = 'no'

And everything run smoothly after deploy.

Share