Websockets require manual setup for docker stacks?

I found recently that with our my application developed in Meteor which uses WebSocket as communication protocol cannot communicate via web sockets. After hours of research, I have found a solution which I would like to see embedded into default Nginx configuration. Solution is based on the following article.

A patch I manually applied to default nginx docker config to make it work with WebSockets:

+ map $http_upgrade $connection_upgrade {
+ default upgrade;
+ '' close;
+ }
listen {{ upstream.port.http }};

And these patch for both locations <pre class="prettyprint"> location / { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; # allow websockets + proxy_set_header Connection $connection_upgrade;


Very help addition that got this working for me (socket.io)

HAProxy configuration:

- container: 5000
  http: 80
  https: 443
- container: 5000
  http: 8080
  https: 8443

and also, in your Nginx config, upgrade may be case sensitive. If you’re using socket.io at least, the above Nginx config needs to be:

map $http_upgrade $connection_upgrade {
     default Upgrade;
     '' close;

Thanks for your addition, Scott! Revised the patch to make it easier to read -> https://gist.github.com/Maxim-Filimonov/a187e480e454e88a4035/revisions

You must be logged in to answer this question