Justin
Justin

Reputation: 410

How to get node.js/socket.IO server work with cloudflare?

I have a node.js/socket.IO server that has been under attack recently, so I decided to start using cloudflare to hide my server IP. However, anyone can easily get the server IP from the client javascript file. Is there anything I can do to connect through cloudflare and not my server directly, so I can help prevent attackers from getting the server IP?

E.g.:

var client = io.connect('http://141.101.xxx.xxx:466');

That would be the IP when I ping the domain that is using cloudflare. I try to connect to it directly.

Even attempting to connect to the domain itself doesn't seem to work

var client = io.connect('http://mydomainthatusescloudflare.com:466');

Only thing that works is directly connecting to the server, without going through cloudflare (thus revealing the IP)

var client = io.connect('http://217.xxx.xxx.xxx:466');

Upvotes: 2

Views: 1924

Answers (1)

400ZP
400ZP

Reputation: 26

You can use cfdomain:80 for socket.io and add this line,

io.set("transports", ["xhr-polling", "jsonp-polling"]);

but disconnected event isnt work. I am trying to fix it.

Upvotes: 1

Related Questions