WebSocket Being Served Via NginX Proxy Now

The NginX server from the Ubuntu LTS repo was 1.1.x and did not support WebSockets. The minimum version of NginX that supports WebSockets is 1.3.13. Note that supports comes in the proxy module. I upgraded to 1.4.1 by compiling from source and the proxy module is enabled by default. Now you can taste WebSockets via NginX proxy at http://pico.simpleit.us/ . Only valid users can log in and fully experience it. If you want to test our new app, comment below.

The WebSocket proxy configuration I used:

server {
    listen 80;
    root /var/www/pico.simpleit.us;

    server_name pico.simpleit.us;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }
}

For the curious, here are the configuration flags I used to compile NginX 1.4.1 (remember to install ssl dev packages)

./configure --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --prefix=/usr --pid-path=/run/nginx.pid --error-log-path=/var/log/nginx/error.log --with-openssl=/usr/lib/ssl

References:

https://chrislea.com/2013/02/23/proxying-websockets-with-nginx/

http://stackoverflow.com/questions/16469581/nginx-and-proxying-websockets

Leave a Reply

Your email address will not be published. Required fields are marked *