如何在nodejs中转发HTTPS流量?
我正在使用nodejs创建一个简单的代理服务器来记录http和https请求,但是,我似乎无法记录https请求(http请求很好) 那么,如何在nodejs中创建一个可以建立安全连接的代理服务器呢 到目前为止,我的代码看起来像如何在nodejs中转发HTTPS流量?,https,node.js,proxy-server,Https,Node.js,Proxy Server,我正在使用nodejs创建一个简单的代理服务器来记录http和https请求,但是,我似乎无法记录https请求(http请求很好) 那么,如何在nodejs中创建一个可以建立安全连接的代理服务器呢 到目前为止,我的代码看起来像 var http = require('http'), httpProxy = require('http-proxy'), util = require('util'), url = require('url'); httpProxy.cre
var http = require('http'),
httpProxy = require('http-proxy'),
util = require('util'),
url = require('url');
httpProxy.createServer(function (request, response, proxy) {
util.log(request.connection.remoteAddress + ": " +
request.method + " " +
request.url);
request.addListener('data', function(chunk) {
util.log("request: " + chunk);
});
uri = url.parse(request.url);
port = 80;
if (uri.protocol == 'https:') { // NEVER HAPPENS :(
port = 443;
}
util.log("port:" + port + " host:" + uri.host);
proxy.proxyRequest(port, uri.hostname);
}).listen(8080);
它目前正在使用代理库,但如果库不支持https(看起来不像是atm,因为在源代码中没有设置任何凭据…),我很乐意在没有它的情况下重写代理服务器。看起来我暂时无法做到这一点,但是有关于新tls模块的文档,它最终将使https连接正常工作 看起来我暂时无法做到这一点,但是关于新的tls模块的文档最终将使https连接正常工作