Organizational Research By

Surprising Reserch Topic

https proxy server in node js


https proxy server in node js  using -'http,node.js,ssl,https,proxy'

I am developing a node.js proxy server application and I want it to support HTTP and HTTPS(SSL) protocols (as server).

I'm currently using node-http-proxy like this:

const httpProxy = require('http-proxy'),
      http = require('http');

var server = httpProxy.createServer(9000, 'localhost', function(req, res, proxy) {
    console.log(req.url);
    proxy.proxyRequest(req, res);
});

http.createServer(function(req, res) {
    res.end('hello!');
}).listen(9000);

server.listen(8000);


I setup my browser to use HTTP proxy on localhost:8000 and it works. I also want to catch HTTPS requests (ie. setup my browser to use localhost:8000 as HTTPS proxy as well and catch the requests in my application). Could you please help me how can I do that?

PS:

If I subscribe to upgrade event of httpProxy server object I can get the requests but I don't know how to forward the request and send response to client:

server.on('upgrade', function(req, socket, head) {
    console.log(req.url);
    // I don't know how to forward the request and send the response to client
});


Any helps would be appreciated.
    
asked Sep 18, 2015 by amit.gupta
0 votes
23 views



Related Hot Questions



Government Jobs Opening


...