apify / proxy-chain

Node.js implementation of a proxy server (think Squid) with support for SSL, authentication and upstream proxy chaining.
https://www.npmjs.com/package/proxy-chain
Apache License 2.0
804 stars 138 forks source link

How to proxy HTTPS? #537

Closed TheGP closed 2 weeks ago

TheGP commented 2 weeks ago

While opening website in a browser (connected to proxy-chain) looks like connect requests skip prepareRequestFunction completely and not redirected to proxy, why? I want to proxy everything.

jancurn commented 2 weeks ago

HTTPS is proxied using so-called HTTP CONNECT tunnel and the prepareRequestFunction function is called once when this tunnel opens. The problem is that web browser typically reuse HTTPS connections to the website for multiple requests, which is transparent to the proxy due to encryption, so the prepareRequestFunction is not called again. You'll need to restart the browser or force it somehow not to reuse HTTPS connections.

jancurn commented 2 weeks ago

I wrote it. The problem is the browser, it just opens one socket for multiple requests. To control the requests, you need to make the browser open new sockets for each request. There's nothing the proxy can do about it.

TheGP commented 2 weeks ago

@jancurn my apologies I re-read it and removed before you answered. How does normal HTTP proxy work then correctly? So proxy-chain should keep connections open then.

jancurn commented 2 weeks ago

Proxy just proxies sockets, but has not idea what data is running in them. That's what the web browser and the web server control.

TheGP commented 2 weeks ago

Yes thats what I want.