Monday, 3 April 2017

NginX-plus does not upgrade my websocket request

I have an issue with websockets throguh Nginx-plus. I have a local setup that works great. It identifies the websocket call and upgrades it accordingly. When I try the same trick on my test platform it does not seem to upgrade my socket.io request. Then my server does only get a load of

2017-04-03T07:51:35.540525525Z info: GET /?EIO=3&transport=polling&t=Liop4yW 404 0.470 ms - 9
2017-04-03T07:51:42.569104508Z info: GET /?EIO=3&transport=polling&t=Liop6fw 404 0.412 ms - 9
2017-04-03T07:51:48.589379184Z info: GET /?EIO=3&transport=polling&t=Liop87f 404 0.350 ms - 9
...

This tells me (as I understand it) that the proxy is working, but the request is not upgraded accordingly. The big difference as I see it is that locally I just run Nginx and on the server I run Nginx-plus. Here is my Nginx-plus configuration:

upstream ws.progress-backend {
    zone ws.progress-backend 64k;
    ip_hash;
    server progress.default.svc.cluster.local resolve;
}

...

location /progress/socket.io/ {
    proxy_pass http://ws.progress;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';

    proxy_http_version 1.1;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
}

My client looks as following:

import io from 'socket.io-client';

...

let options = { path: '/progress/socket.io' };
io.connect(getWebAPI().getURL(), options);

On server side:

let io = require('socket.io')( server, { path: '/progress/socket.io' } );

As I said, the setup works locally, but for Nginx-plus it seems like it won't upgrade my request. Any thoughts would be welcome.



via David Gustavsson

No comments:

Post a Comment