http-party / node-http-proxy

A full-featured http proxy for node.js
https://github.com/http-party/node-http-proxy
Other
13.89k stars 1.97k forks source link

[Question] it's possible to proxy browser request ? #1137

Open ghost opened 7 years ago

ghost commented 7 years ago

Hello, i need your help because i'm stupid.

I don't understand this lib. It's one Nginx like?

I search lib for proxy my browser for modify response on the fly but is this possible with this lib? I would like the target port to be the same as the listen port.

I have this code for my actual proxy server (it's juste skeleton code, it's to explain).

var http = require('http');
var request = require('request');
var port = 8000;

var server = http.createServer(function(req, res) {
  req.pipe(request(req.url)).pipe(res);
}).listen(port);

But it drop https request and i need server that is transparent with this, i tested this lib but i think it does not serve at all what I thought at the start :'(

Sorry, i'm noob, thanks for your help.

brugnara commented 7 years ago

@Nw-Fig you can not proxy https in transparent mode. You need SSL certs but if you want to use as a browsing proxy, you have to let https pass directly.

ghost commented 7 years ago

Yes, i want do this, but I don't understand if i can use this lib for that, for proxy browser/system http request, return a modified response and ignore https responses.

I think i am misled by the name of this lib because i don't find how use createProxyServer for my case, without target one port, just listen one port and pipe modified response inside, as in my example.

Thanks for your response.

sposmen commented 7 years ago

@Nw-Fig recently I was figuring something similar, but there is a different kind of http proxies like this, focused on listen same domain and passing through its requests to another server with some changes like headers or kind of, and another ones catching al http petitions, caching on any domain request like Squid... something where https://www.npmjs.com/package/proxy code could help you better on what you want to reproduce... I just checked with https and worked. The difference on both kinds is described here https://en.wikipedia.org/wiki/Proxy_server#Types