Gireesh
Gireesh

Reputation: 706

Node https forward proxy client-server

I'm trying to use Node's request module to make a request to https url. Code snippet below.

var request = require('request')
,r = request.defaults(
      {'proxy':'https://localhost:8443',
        strictSSL: false, 
        rejectUnauthorized: false,
      });

function sendHttpsReq(){
r.get('https://my.https.url/api/model', function (error, response, body) {
    if (!error && response.statusCode == 200) {
          console.log(body);
       }
    });
}

Using the above code, If i use a http proxy and make a http request, the proxy server gets the request. But for a https url through a https proxy, the proxy server never gets the request. I'm using a simple node-http-proxy based proxy server running on my local server.

Upvotes: 0

Views: 3036

Answers (1)

Gireesh
Gireesh

Reputation: 706

Looks like multiple people had issue with node-http-proxy when using it as https forward proxy.

The following issues are logged on their github repository.

https://github.com/nodejitsu/node-http-proxy/issues/453

https://github.com/nodejitsu/node-http-proxy/issues/454

I had to deviate from using node-http-proxy for https forward proxy instead used the code from following blog.

http://newspaint.wordpress.com/2012/11/05/node-js-http-and-https-proxy/

Upvotes: 5

Related Questions