不要将 ProxyPass 设置为 Localhost!那是行不通的!
在您的 Apache 配置中执行此操作:
<VirtualHost *:443>
ServerName domain.com
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
ProxyPass / https://domain.com:3000/ retry=1 acquire=3000 timeout=600 Keepalive=On
ProxyPassReverse / https://domain.com:3000/
SSLEngine on
SSLCertificateKeyFile /etc/ssl/private/domain.com.key
SSLCertificateFile /etc/ssl/certs/domain.com.crt
SSLCertificateChainFile /etc/ssl/certs/chaincert.crt
</VirtualHost>
现在,Nodejs 也可以拥有 SSL:
var express = require('express');
var connect = require('connect');
var app = express();
var fs = require('fs');
var ssl_options = {
key: fs.readFileSync('/etc/ssl/private/domain.com.key'),
cert: fs.readFileSync('/etc/ssl/certs/domain.com.crt'),
ca: fs.readFileSync('/etc/ssl/certs/domain.com.ca')
};
var server = require('https').createServer(ssl_options, app);
var port = process.env.PORT || 3000;
var io = require('socket.io')(server);
server.listen(port, function(err) {
console.log(colors.green('https server running on port ' + port));
});
在您的客户中执行以下操作:
var socket = io.connect('https://domain.com:3000', { path: '/socket.io', 'flash policy port': 3000 });
对我来说,这很好用!