我想知道设置代理的最简单方法,我可以在其中发出 HTTP 请求(即)localhost:8011
,并且代理发出 HTTPS 请求localhost:443
(来自服务器的 HTTPS 应答也应该由代理转换为 HTTP)
我正在使用 node.js
我试过http-proxy
这样:
var httpProxy = require('http-proxy');
var options = {
changeOrigin: true,
target: {
https: true
}
}
httpProxy.createServer(443, 'localhost', options).listen(8011);
我也试过这个:
httpProxy.createProxyServer({
target: {
host:'https://development.beigebracht.com',
rejectUnauthorized: false,
https: true,
}
}).listen(port);
但是当我尝试连接时,我收到了这个错误
/Users/adrian/Development/beigebracht-v2/app/webroot/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:103
var proxyReq = (options.target.protocol === 'https:' ? https : http).reque
^
TypeError: Cannot read property 'protocol' of undefined
我想用节点来做,但是,其他解决方案可能是有效的。(代理将在 localhost 中使用,仅用于测试目的,因此安全性不是问题)