Forward Proxy
SteveSelva opened this issue · 0 comments
I am making a Forward HTTPS Proxy Server using Proxygen
.
When I analyzed the code, I came to know that HTTPSession
is first created over the socket with HTTP version and TLS details wrapped in it.
With that session, for each request, a HTTPTransaction
is created and handled by the RequestHandler
.
RequestHandler
acts as a downstream manager and ResponseHandler
acts as a upstream manager.
After the request is completed, the transaction is deleted. After a certain period, if no transactions remain in the session, session also gets destroyed based on idleTimeout
or HTTP Protocol.
In Forward HTTPS Proxy,
Every connection starts with CONNECT
Request with HTTP/1.1 and without TLS.
The CONNECT
request received from the downstream should be and forwarded to upstream.
But the handling of both downstream and upstream are different.
In Downstream, for CONNECT
Request, Connection Established with 200 Response Code should be sent and TLSHandshake should be done(waiting for ClientHello
message from Downstream). And TLS connection should be established.
In Upstream, CONNECT
Request should be forwarded from the server, and the upstream should wait until Connection Established Message with 200 Response Code is return and then TLSHandshake should be done(send ClientHello
message to Upstream). And TLS connection should be established.
When both sides(downstream and upstream) have established TLS connections, the proxy would function normally, like forwarding the request from downstream to upstream and then forwarding the response from upstream to downstream.
How to configure Proxygen
to work as Forward HTTPS Proxy Server?