简体   繁体   English

node.js、socket.io 和 SSL

[英]node.js, socket.io and SSL

I have an Apache server running with SSL enabled.我有一个启用 SSL 的 Apache 服务器。 Now I made a small chat which is using node.js and socket.io to transmit data.现在我用node.js和socket.io传输数据做了一个小聊天。 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.在非安全连接上使用端口 8080 工作正常,但是当我在 SSL 安全域上尝试时它不起作用。 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?我不明白整个设置应该如何工作,因为 SSL 只通过端口 443 工作。Apache 已经在端口 443 上列出。socket.io 应该在哪个端口上监听?

I had to set the SSL certificates like我必须设置 SSL 证书,例如

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我在github上找到了解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM