我想爲Node.js創建HTTPS
連接的代理。我正在使用http-proxy
庫,效果很好。我可以得到一個HTTP
代理工作完美,但是當我嘗試HTTPS
時,對代理的請求只是超時。這裏是我的代碼(稍微修改了node-http-proxy
proxy-https-to-https
例子的版本):Node.js HTTPS代理服務器不工作
var http = require("http"),
https = require("https"),
httpProxy = require("http-proxy"),
fs = require('fs');
var httpsConfig = {
key: fs.readFileSync('./jackos2500-key.pem'),
cert: fs.readFileSync('./jackos2500-cert.crt'),
};
https.createServer(httpsConfig, function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('hello https\n');
res.end();
}).listen(8000);
httpProxy.createServer(8000, 'localhost', {
https: httpsConfig,
target: {
https: true,
rejectUnauthorized: false
}
}).listen(443);
是有我丟失在這裏還是有一些其他的問題了一些東西明顯?
一個開放的問題。這是否有助於洞察力? – Roemer 2013-05-10 19:58:28