Friendly and scalable websocket server for applications

Channelstream behind NGINX proxy

To run websocket server behind a reverse-proxy you need to turn gzip responses off and send upgrade headers. Here is an example config required to create websocket connections.

upstream backend_channelstream_server {
    server weight=1 max_fails=5 fail_timeout=30s; #comment

server {
    listen 80;
    server_name ;

    root /var/www/;

    access_log /var/log/nginx/;
    error_log /var/log/nginx/;

    location / {
            client_max_body_size    1m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   390;
            proxy_send_timeout      390;
            proxy_read_timeout      390;
            tcp_nodelay             off;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Url-Scheme $scheme;
            gzip off;
            proxy_pass http://backend_channelstream_server;