calzoneman / sync

Node.JS Server and JavaScript/HTML Client for synchronizing online media
Other
1.46k stars 235 forks source link

Socket io reverse proxy, Duplicate of #528 #808

Closed peterkyl closed 5 years ago

peterkyl commented 5 years ago

I have configured an niginx reverse proxy very similar to the one in the old #528 issue and ran into the same problem of everyone's "remote address" being the server ip. From what I found looking at the history of ioserver.js and messing around with the function at ln51 of ioserver.js, ipProxyMiddleware, CyTube is supposed to support X-Forwarded-For. I got it working by changing ln56 from socket.handshake.address to socket.handshake.headers['x-forwarded-for'].

Did I miss something in the config.yaml maybe?

Do you still recommend NOT proxying socket io? Do you intend to support this feature?

calzoneman commented 5 years ago

If you aren't reverse proxying to a loopback address (e.g. 127.0.0.1), then you will need to alter the trust-proxies config: https://github.com/calzoneman/sync/blob/3.0/config.template.yaml#L74

peterkyl commented 5 years ago

I changed the proxy address to 127.0.0.1 and loopback in the config and it worked! I was using linklocal and 10.0.0.15, my server local ip, and that didnt work. Thanks!