Do servers send responses back to proxy servers or directly to clients? - http

Given a client sending requests to a proxy server. The proxy server forwards the requests to another server.
Does this "other" server send the response directly back to the client like so
or does it send the response to the proxy server and the proxy server sends the response back to the client like so

Related

Is there an HTTP response code for a proxy to make browser directly connect to target?

I want to set up a custom proxy that proxies connections to some destinations (inside a network) but not other destinations (in the global internet). Is there any HTTP response the proxy server can send to make the browser connect directly to the requested destination?
For example, I request redirection to Google to my proxy server. The proxy server decides not to proxy, so I get this HTTP response, and my browser connects directly to Google.
You could send a redirect http response code like 302 to redirect the client directly to the website. See: https://moz.com/learn/seo/redirection

How can a Netty Server porcess a client request using another Netty Client for Http2 Proxy Server

My requirement is if a browser sends the request to ServerBootStrap then the ServerBootStrap creates BootStrap (Client) and that client connects with a proxy server.
The problem here is to connect with Proxy Server we need to send first HTTP CONNECT method to open a tunnel from Proxy and BootStrap (Client) and then whatever request comes from Browser to Server, the server will send BootStrap(client) and all the communication should happen.
This will look like
Browser ->ServerBootStrap(Server)->BootStrap(Client)->ProxyServer(HTTP2)
Can somebody tell me how do I implement this for Http2?
How do I send Http CONNECT from a Handler for the First time while Client instantiating and If CONNECT gets 200OK from Proxy Server I will to remove Handler from channel pipeline?
Can we explicitly call any HTTP CONNECT request while adding a handler in Pipeline and getting the response to check the status?
--Can somebody answer ?

Does http CONNECT method get proxy relay data at TCP level?

This is the question about HTTP CONNECT method.
I learned that after CONNECT request from client a TCP connection is established between proxy and remote server.
Then, at the step of SSL handshake, does the proxy evaluate and relay any http data from client up to at TCP level? So the data is not passed to application level of the proxy?
I understood that after SSL session establishment any data from client is encrypted and the proxy cannot read those. But how about the time before SSL session establishment, that is, SSL handshake step?
After the proxy has sent a successful response to the clients CONNECT request a normal proxy will forward all data between client and server without any changes. This includes the TLS handshake for HTTPS connections tunneled using CONNECT.
Note that there are proxies which do SSL interception (typically at firewalls). In this case the data are not blindly forwarded but the proxy will be an active man in the middle which means that the client does not receive the original certificate from the server and that the proxy will decrypt and maybe even modify the traffic between client and server.

How to add additional headers in https proxy?

I created on golang double HTTP proxy server. Server receives request, adds additional headers in this request and sends this changed request to another proxy server, which read this headers, remove it from request, and finally make request into destination.
With HTTP it works perfect. But how create this with HTTPS ?!
In HTTPS request browser send http CONNECT request, and then send encrypted data. Can i decrypted this data with CA signed server certificate, then add headers, send HTTPS request to another server, and then send HTTPS request to destination !?

Does nginx upstream server compress response data before it sends back to midstream server?

Here is my situation, browsers send http requests to my reverse proxy nginx server, my reverse proxy nginx server then ask upstream server for response, I was wondering whether upstream server will check if request header has "Accept-Encoding:gzip" and compress response data or just send raw data back to my reverse proxy nginx server?
Because when I use tcpdump to capture http response from upstream server to my nginx server,
I could see so much raw data there.

Resources