如何使用带节点的http代理。js https吗?

时间:2021-04-19 19:00:01

I want to make an https request call from node.js, using the standar https Client. But I cannot reach the remote server directly from my network and need to go through a proxy.

我想从node发出一个https请求调用。使用标准https客户端。但我无法直接从网络到达远程服务器,需要通过代理。

How do I tell node.js to use the proxy? I tried option as following the post

如何告诉节点。js使用代理吗?我试着按下面的帖子做选择

{ path : 'https://api.xxx.com:8081/token';
host : 'proxy-us.xxxx.com';
port : 8082;
method : POST_METHOD;
headers : {
    'host':  "api.xxx.com:8081"
}

But never reached

但从未到达

1 个解决方案

#1


3  

I am a big fan of Mikeal's request module. It makes http requests very easy and has many features such as proxy support, streaming, forms, auth and oauth signing. Here is a proxy example:

我非常喜欢Mikeal的请求模块。它使http请求非常容易,并且具有许多特性,如代理支持、流、表单、auth和oauth签名。下面是一个代理示例:

var request = require('request');
request({'url':'https://api.xxx.com:8081/token',
         'proxy':'http://proxy-us.xxxx.com:8082'}, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Print the google web page.
  }
})

#1


3  

I am a big fan of Mikeal's request module. It makes http requests very easy and has many features such as proxy support, streaming, forms, auth and oauth signing. Here is a proxy example:

我非常喜欢Mikeal的请求模块。它使http请求非常容易,并且具有许多特性,如代理支持、流、表单、auth和oauth签名。下面是一个代理示例:

var request = require('request');
request({'url':'https://api.xxx.com:8081/token',
         'proxy':'http://proxy-us.xxxx.com:8082'}, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Print the google web page.
  }
})