Aley
Aley

Reputation: 8640

node.js, socket.io and SSL

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?

Upvotes: 2

Views: 3344

Answers (1)

Aley
Aley

Reputation: 8640

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

Upvotes: 3

Related Questions