How do I properly create a transparent HTTPS proxy using node?

I am using the npm http-proxy package which claims to help with this, however I am completely unable to get it to work. So far I only have success creating a transparent HTTP proxy, however, when it is about to create a transparent HTTPS proxy, nothing happens.

I am using an android device configured to use a proxy with a port where the proxy is expected to be configured but nothing starts up on the nodejs side. Only if I have configured an HTTP proxy then everything works.

This is the code I have for HTTPS:

var https = require('https');
var fs = require('fs');
var httpProxy = require('http-proxy');

var options = {
    key: fs.readFileSync('./client-key.pem', 'utf8'),
    cert: fs.readFileSync('./client-cert.pem', 'utf8')
};

var proxy = httpProxy.createProxyServer({
    ssl: options
});

https.createServer(options, function (req, res) {
    console.log("new", req.url);
    proxy.web(req, res, {
        target: req.url
    });
}).listen(8000);

      

If I use createServer from the http package, it works for http calls (as in what calls the callback), however it is not for https with this instruction. Does anyone know what I am doing wrong?

PS: I don't care if I need to use a different npm package.

+3
node.js https proxy


source to share


No one has answered this question yet

Check out similar questions:

1710
What's the difference between a proxy and a reverse proxy?
891
How is an HTTP POST request made in node.js?
880
Getting git to work with a proxy
867
How to remove npm modules in js node?
466
node how to create directory if it doesn't exist?
458
How can I checkout from a Git repository via an HTTP proxy?
337
How do I create an HTTPS server in Node.js?
38
npm http-server with SSL
0
HAProxy using an external proxy and Client-Cert
0
from HTTP to HTTPS proxy without modification



All Articles
Loading...
X
Show
Funny
Dev
Pics