我想为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