I have an Apache server running with SSL enabled. Now I made a small chat which is using node.js and socket.io to transmit data. Using port 8080 on a none secured connection is working just fine, but when I try it on a SSL secured domain it is not working. I do not get how the whole setup should work since SSL is only working through port 443. Apache is already listining on port 443. On which port should socket.io listen?
Asked
Active
Viewed 3,321 times
2
-
1Possible duplicate of http://stackoverflow.com/questions/6599470/node-js-socket-io-with-ssl – Fallexe Jun 01 '13 at 02:55
-
@Fallexe not really. He is using node.js without Apache. In my case Apache is already using port 443 – Aley Jun 01 '13 at 09:45
-
I've never tried to run Apache and socket on the same port, but here is something similar w/o ssl http://stackoverflow.com/questions/11172351/how-to-put-nodejs-and-apache-in-the-same-port-80 – Fallexe Jun 01 '13 at 10:28
1 Answers
3
I had to set the SSL certificates like
var fs = require('fs');
var options = {
key: fs.readFileSync('/etc/ssl/ebscerts/wildcard.my_example.com.no_pass.key'),
cert: fs.readFileSync('/etc/ssl/ebscerts/wildcard.my_example.com.crt'),
ca: fs.readFileSync('/etc/ssl/ebscerts/bundle.crt')
};
var app = require('https').createServer(options),
io = require('socket.io').listen(app);
app.listen(8080);
I found the solution on github

Aley
- 8,540
- 7
- 43
- 56