2

I feel like this question might be a duplicate but from all similar threads I have checked still wasn't able to find a answer.

I have vhost setup to proxy /node/ request to NodeJS/Socket.IO server.

ProxyRequests On
ProxyPass /node http://192.168.2.151:1337/
ProxyPassReverse /node http://192.168.2.151:1337/

This setup successfully serves everything from Apache, expect requests: http://domain.com/node/ Everything works fine when it comes to NodeJS.

I just can't get this line:

<script src="/node/socket.io/socket.io.js"></script>

to load socket.io.js, it always spits out what NodeJS server has to say.

The setup:

index.html is served by Apache. http://domain.com/index.html index.html is simple HTML with script tag for loading socket.io.js (like I wrote above). When I request http://domain.com/index.html script src is loaded but the content is NodeJS servers response instead of socket.io.js.

I have 'npm install socket.io' in the directory where NodeJS server is running from.

I have tried to serve index.html with NodeJS as well, regardless - socket.io.js content is still NodeJS responce.

Did anyone had this problem? Or could link me to an answer? :)

Cheers!

rock3t
  • 2,193
  • 2
  • 19
  • 24

1 Answers1

0

Look at this question and all of the answers at serverfault: Configuring Apache2 to proxy WebSocket?.

The problem is that mod_proxy doesn't support WebSockets and just makes it an HTTP request. You could use a different port and avoid proxying, switch to Nginx, try haproxy or use various other Apache module alternatives. For instance, mod_proxy_wstunnel is basically mod_proxy with WebSockets support. See the serverfault link above for details on all of the solutions.

DaAwesomeP
  • 585
  • 5
  • 18