0

I'm trying to create my own proxy server in NodeJs with the library node-http-proxy the problem is that I want to create a http proxy server that will have the possibility to forward the request to a https target (ex. https://google.com).

I know it's possible, because there is already a library that does this called: proxy-chain

When I try to request a https target with node-http-proxy I get an error: ERR_EMPTY_RESPONSE.

It also states in the documentation that I need to add a PKCS12 client certificate, but the proxy-chain does not do this.

Is there a way I can replicate the proxy-chain library with the node-http-proxy library?

This is my code at the moment:

var proxy = httpProxy.createProxyServer({});

var server = http.createServer(function(req, res) {
  // You can define here your custom logic to handle the request
  // and then proxy the request.
  proxy.web(req, res, {
    target: {
        hostname: 'github.com',
        port: 433,
        protocol: 'https',
    },
    secure: false,
    changeOrigin: true
  });
});

console.log("listening on port 5050")
server.listen(5050);
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
SaltyPotato
  • 192
  • 2
  • 14

0 Answers0