我正在尝试设置我的 SocketCluster 应用程序以使用 SSL。我可以让它在没有 ssl 的情况下在 nginx 上工作,但不能使用它。每当我在浏览器中访问该站点时,我都会看到 nginx 欢迎页面。如果我在浏览器中访问端口 8000,我可以看到套接字集群,但如果使用 https 协议则看不到。
nginx 配置
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/server.crt;
ssl_certificate_key /etc/ssl/server.key;
server_name 104.xxx.54.xxx;
access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass https://localhost:8000;
proxy_redirect off;
}
}
服务器.js
var argv = require('minimist')(process.argv.slice(2));
var SocketCluster = require('socketcluster').SocketCluster;
require('dotenv').config();
var socketCluster = new SocketCluster({
workers: Number(argv.w) || 3,
brokers: Number(argv.b) || 1,
port: Number(argv.p) || 8000,
path: '/socket',
appName: '...',
workerController: __dirname + '/worker.js',
brokerController: __dirname + '/broker.js',
socketChannelLimit: 1000,
crashWorkerOnError: argv['auto-reboot'] != false,
rejectUnauthorized: false,
secure: true
});