如何在nodejs中转发HTTPSstream量?

我使用nodejs来创build一个简单的代理服务器,logginghttp和https请求,但是,我似乎无法得到https请求被logging(http请求是好的)

那么如何在nodejs中创build一个可以build立安全连接的代理服务器呢?

我的代码至今看起来像

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://github.com/nodejitsu/node-http-proxy代理库,但是如果库不支持https(看起来不像是atm,因为没有在源代码中的任何地方设置任何凭据….),我很高兴重写代理服务器没有它。

看起来我暂时无法做到这一点,但有新的tls模块的文档,最终使https连接正常工作。 https://github.com/ry/node/blob/5a87bd168d8fbeca7d48b9ddaa3b4e8a9336719c/doc/api/tls.markdown