Why Can an HTTP Proxy Handle HTTPS Requests?
An HTTP proxy can use CONNECT to switch a connection into tunnel mode. Its main job then becomes forwarding data in both directions, rather than reading each website request inside the tunnel.
Two frequently conflated descriptions need to be distinguished:
| Description | Actual meaning | What is protected or carried |
|---|---|---|
| An HTTP proxy supports HTTPS destinations | The proxy permits a CONNECT tunnel to the destination | The tunnel carries TLS communication between the client and the website |
| The client connects to the proxy over HTTPS | The connection from the client to the proxy gateway itself uses TLS | Protects the client-to-proxy connection |
The first does not automatically mean the second is enabled. Even when the client connects to the proxy over plain HTTP, TLS can still protect HTTPS content between the client and the target website after the tunnel is established.
This article covers conventional HTTP/1.1 CONNECT and ordinary tunnel forwarding. It does not cover specialized deployments that terminate TLS and inspect content.
What Does the Client Send to the Proxy First?
The client first sends a CONNECT request specifying the target host and port. At this point, it is asking to establish a communication channel; it has not yet sent the actual page or API request to the website.
For example, to access https://example.com/status, the tunnel-establishment request can look like this:
CONNECT example.com:443 HTTP/1.1
Host: example.com:443This illustrative message contains three key elements:
- CONNECT: Requests a tunnel, unlike the GET method commonly used to retrieve a page.
- Target host: Here,
example.comtells the proxy which destination to connect to. - Target port: This example uses port 443, commonly used for HTTPS. CONNECT requires an explicit port.
The path /status is not included in this CONNECT request. It belongs to the subsequent website request and is sent as encrypted HTTP data after TLS is established.
How Does the Proxy Establish the Tunnel and Return a Result?
The proxy checks the request, connects to the destination, and returns a successful CONNECT response if the connection is established. Checks may involve proxy authentication, the destination port, and access policies.
| Step | What the proxy does | What it means for the client |
|---|---|---|
| Parse the request | Reads the target host and port | The request must have a valid format |
| Check authorization | Determines whether proxy authentication is required | The client may first receive a 407 authentication response |
| Check the destination | Determines whether the target and port are permitted | CONNECT does not mean every port is open |
| Establish the connection | Connects directly to the destination or uses a configured upstream proxy | Tunnel establishment may fail if the destination is unreachable |
| Return success | Sends a 2xx response and enters tunnel mode | The client can begin TLS communication |
A typical successful response looks like this:
HTTP/1.1 200 Connection EstablishedThis 200 means the tunnel was established successfully. It is not a 200 response from the target page. The website's application response arrives only after the TLS handshake and actual website request have completed.
Who Performs the TLS Handshake with the Client?
In ordinary CONNECT tunnel mode, the website TLS handshake takes place between the client and the target website. The proxy forwards the handshake messages, but this does not make it an endpoint of the website's TLS connection.
During this stage, the client verifies the target website's identity and establishes the cryptographic parameters needed to protect subsequent communication. The sequence can be understood as follows:
- The client initiates a TLS handshake through the tunnel.
- The target server returns handshake information and its certificate.
- The client validates the certificate and checks that it matches the target name.
- Both sides complete the handshake and begin exchanging protected application data.
A certificate validation failure occurs during HTTPS connection establishment. A successful CONNECT does not remove the need to verify the website's identity, and a certificate error should not be interpreted directly as a missing page.
Which Paths Do HTTPS Requests and Responses Follow?
After TLS is established, the client encrypts its website request and sends it through the proxy to the destination. The encrypted response returns over the established connections. The proxy forwards data in both directions.
Establish the channel: Client → CONNECT request → Proxy → Target host and port
Establish encryption: Client ← TLS handshake relayed by proxy → Target website
Send the request: Client → Encrypted request → Proxy → Target website
Return the response: Client ← Encrypted response ← Proxy ← Target websiteConsider a shipment-tracking application accessing an HTTPS API:
| Stage | Who handles the application content? | What does the proxy do? |
|---|---|---|
| Construct the API request | The client generates the path, parameters, and request body | It has not yet handled the API request |
| Send the request | The client encrypts it; the website decrypts and processes it | Forwards encrypted data |
| Return the result | The website generates and encrypts the API response | Relays the encrypted data to the client |
| Read shipment fields | The client decrypts and parses the response | Does not identify shipment-status fields |
Forwarding an HTTPS request does not mean the proxy has read its body. Forwarding bytes and understanding application content are different capabilities.
What Information Can an Ordinary Tunnel Proxy See?
An ordinary tunnel proxy generally knows the connection destination and traffic characteristics, but cannot directly read application content protected by TLS. This assumes certificate validation works correctly and there is no specialized TLS-termination deployment.
| Information | Visibility in an ordinary CONNECT tunnel |
|---|---|
| Source address of the client's connection to the proxy | The proxy can identify the connection source |
| Host and port in CONNECT | The proxy can read them to establish the destination connection |
| Connection duration and data volume | The proxy can observe them |
| Encrypted page path and query parameters | Cannot be read directly from TLS application data |
| Encrypted request body, cookies, and response body | Cannot be read directly from TLS application data |
Protected application content does not mean all connection information is invisible. Distinguish connection metadata from application content when deciding what to log or analyzing access paths.
Conclusion
An HTTP proxy handles HTTPS by first establishing a CONNECT tunnel, after which the client and target website communicate using TLS. Distinguishing tunnel establishment, handshake completion, and application-response success makes it easier to understand request and response paths and what the proxy can see.
FAQ
Q: Why can HTTPS access fail even after the connection to the HTTP proxy succeeds?
Access proceeds through several stages: the proxy connection, CONNECT, the TLS handshake, and website application processing. A failure at any later stage can prevent the page from being returned. Identify the last successful stage first, then examine the errors that follow it.
Q: Can the website return another status code after CONNECT returns 200?
Yes. The CONNECT 200 is the proxy's response to tunnel establishment. The website then returns its own status code for the application request. For example, the tunnel can succeed while the website reports a missing resource or insufficient permissions. These responses describe different outcomes.
Q: Do you need to install a proxy certificate to use an ordinary CONNECT tunnel?
In ordinary tunnel mode, the client validates the target website's certificate. An additional root certificate is usually not needed for the tunnel itself. If a deployment requires trusting website certificates issued by the proxy, check separately whether it involves TLS termination and content inspection.
Q: Can the proxy cache HTTPS pages inside the tunnel?
An ordinary tunnel proxy cannot see complete HTTP messages protected by TLS, so it cannot directly cache these responses based on page semantics. Proxy caching and tunnel forwarding are different operating modes. Ordinary HTTP caching capabilities cannot simply be applied inside an HTTPS tunnel.
Q: Can traditional CONNECT directly carry HTTP/3?
A traditional TCP CONNECT tunnel should not be treated as a UDP channel. HTTP/3 uses QUIC over UDP. Proxy support requires checking the client, proxy, and relevant extensions; a statement that a product “supports HTTPS” is not sufficient.