Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 侦听nodejs中的https流量_Node.js_Https_Reverse Proxy - Fatal编程技术网

Node.js 侦听nodejs中的https流量

Node.js 侦听nodejs中的https流量,node.js,https,reverse-proxy,Node.js,Https,Reverse Proxy,我需要监听https流量,我的代码可以监听所有http流量,但无法捕获https。我怎么做? 这是我的密码 var http = require('http'); var url = require('url'); var fs = require('fs'); http.createServer(function(request, response) { var url_part = url.parse(request.url,true); var originUrl = url_part.h

我需要监听https流量,我的代码可以监听所有http流量,但无法捕获https。我怎么做? 这是我的密码

var http = require('http');
var url = require('url');
var fs = require('fs');
http.createServer(function(request, response) {
var url_part = url.parse(request.url,true);
var originUrl = url_part.href;
var options = url.parse(originUrl);
var proxy = http.request(options);
proxy.addListener('response', function (proxy_response) {
    proxy_response.addListener('data', function(chunk) {
       response.write(chunk, 'binary');        
    });
    proxy_response.addListener('end', function() {
       response.end();
    });
    response.writeHead(proxy_response.statusCode, proxy_response.headers);
 });
 request.addListener('data', function(chunk) {
    proxy.write(chunk, 'application/json');

 });
 request.addListener('end', function() {
    proxy.end();
 });
 }).listen(3128);

使用
https
模块,请参考文档Hi,我已经使用了https模块。这是我的代码很抱歉,我将其发送到此链接太长了,但当我使用ip连接到代理服务器时,端口会显示ERR_EMPTY_响应如何修复它?我看不到
https
模块,您正在使用
http
@ArifKhan我已经使用了另一个代码,这是我的代码,请再次查看它有什么问题,您可以同时侦听http和https,但端口不同