Remove port from Socket.IO and change directory

Using Apache on Ubuntu 15.04 I am trying to effectively remove port 3000 from the url and also change the path to http://example.com/{app}/socket.io...

Using ProxyPass and ProxyPassReverse I removed the port from the URL efficiently and also updated the server and client side, respectively, to change the path.

Virtual Host Changes:

 ProxyPass /path/ http://example.com:3000/path/ ProxyPassReverse /path/ http://example.com:3000/path/ 

The server-side changes I made were as follows:

 var io = require('socket.io')(http, {path: '/path/socket.io' }); app.get('/path/', function(req, res){ 

and the client changes I made were as follows:

 var socket = io({path: '/path/'}); 

Everything seemed to work smoothly until I opened my console log and saw a lot of GET requests when using chrome. This will definitely kill my tape, and I think that for some reason I was not able to listen to the socket correctly, which led to a massive number of GET requests.

Can someone give some guidance on what I can do wrong?

+6
source share
1 answer

You see a large number of requests, as socket.io returns to a long poll, since Apache does not proxy the connection to the web site, which you will need to enable with

 mod_proxy_wstunnel 

then add

 ProxyPass "/path/socker.io" "ws://localhost:3000/" 
0
source

All Articles