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.
source to share
No one has answered this question yet
Check out similar questions: