感谢大家对这个问题的贡献。我真的很感激所有的指点!
特别提到 JohnnyHK,他的建议让我走上了正轨。我能够使用 node-http-proxy 解决我的问题。简单有效!下面是我的 server.js 现在的样子:
var MyApp = require('./lib/app');
var fs = require('fs'),
http = require('http'),
https = require('https'),
httpProxy = require('http-proxy');
var options = {
https: {
key: fs.readFileSync('certs/server.key', 'utf8'),
cert: fs.readFileSync('certs/server.crt', 'utf8'),
ca: fs.readFileSync('certs/ca.crt', 'utf8')
},
target: {
https: true // This could also be an Object with key and cert properties
}
};
var app = new MyApp({
port: 8080
});
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: 8080
}
});
https.createServer(options.https, function (req, res) {
proxy.proxyRequest(req, res)
}).listen(443);
再次感谢大家!
——诺曼 A。