我有一个 locomotive.js MVC 项目,它在 http 上监听。我想在 https 上收听,并将所有 http 重定向到 https。
我找不到node.js的createServer,我找到的唯一代码是:/lib/node_modules/locomotive/lib/locomotive/cli/server.js
console.log('booting app at %s in %s environment', dir, env);
locomotive.boot(dir, env, function(err, server) {
if (err) {
throw err;
}
server.listen(port, address, function() {
var addr = this.address();
console.log('listening on %s:%d', addr.address, addr.port, addr);
});
});
变成 :
console.log('booting app at %s in %s environment', dir, env);
var crypto = require('crypto'),
fs = require("fs");
var privateKey = fs.readFileSync('/privatekey.pem').toString();
var certificate = fs.readFileSync('/certificate.pem').toString();
var https = require('https');
var credentials = crypto.createCredentials({key: privateKey, cert: certificate});
我现在有点卡住了,有什么帮助吗?
谢谢 !