Question

My node server and Faye are configured to run on port 3000. I have set up the following in apache to make it run on port 80 through a reverseproxy:

<VirtualHost *:80>
  ServerAdmin spam@example.com
  ServerName server.com
  DocumentRoot /var/www/html/nodejs-chat
  ProxyPass / http://localhost:3000/
  ProxyPassReverse / http://localhost:3000/
</VirtualHost>

This works great, except for the fact that I have the following set up for Faye, client-side:

var client = new Faye.Client('http://188.0.0.1:3000/faye');

So for websockets using Faye, port 3000 is still being used when creating the client and I've noticed that many firewalls block that connection and my application stops working.

I can't seem to figure out how to also proxy reverse that client-side code. I've tried:

var client = new Faye.Client('http://server.com/faye');

But that didn't work out:

WebSocket connection to 'ws://server.com/faye' failed: Error during WebSocket handshake: Unexpected response code: 400

Has anyone done the same thing with Faye?

Was it helpful?

Solution

I found out what the problem was. In case anyone else is having this issue, here's the deal:

Apache 2.2 doesn't really support proxying web sockets. There's a module available, but it requires you to rebuild apache manually and that's not a route I want to take here.

What I did was swap apache for nginx, which supports web sockets nicely even in combination with a reverse proxy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top