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:

DescriptionActual meaningWhat is protected or carried
An HTTP proxy supports HTTPS destinationsThe proxy permits a CONNECT tunnel to the destinationThe tunnel carries TLS communication between the client and the website
The client connects to the proxy over HTTPSThe connection from the client to the proxy gateway itself uses TLSProtects 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:443

This illustrative message contains three key elements:

  • CONNECT: Requests a tunnel, unlike the GET method commonly used to retrieve a page.
  • Target host: Here, example.com tells 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.

StepWhat the proxy doesWhat it means for the client
Parse the requestReads the target host and portThe request must have a valid format
Check authorizationDetermines whether proxy authentication is requiredThe client may first receive a 407 authentication response
Check the destinationDetermines whether the target and port are permittedCONNECT does not mean every port is open
Establish the connectionConnects directly to the destination or uses a configured upstream proxyTunnel establishment may fail if the destination is unreachable
Return successSends a 2xx response and enters tunnel modeThe client can begin TLS communication

A typical successful response looks like this:

HTTP/1.1 200 Connection Established

This 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:

  1. The client initiates a TLS handshake through the tunnel.
  2. The target server returns handshake information and its certificate.
  3. The client validates the certificate and checks that it matches the target name.
  4. 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 website

Consider a shipment-tracking application accessing an HTTPS API:

StageWho handles the application content?What does the proxy do?
Construct the API requestThe client generates the path, parameters, and request bodyIt has not yet handled the API request
Send the requestThe client encrypts it; the website decrypts and processes itForwards encrypted data
Return the resultThe website generates and encrypts the API responseRelays the encrypted data to the client
Read shipment fieldsThe client decrypts and parses the responseDoes 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.

InformationVisibility in an ordinary CONNECT tunnel
Source address of the client's connection to the proxyThe proxy can identify the connection source
Host and port in CONNECTThe proxy can read them to establish the destination connection
Connection duration and data volumeThe proxy can observe them
Encrypted page path and query parametersCannot be read directly from TLS application data
Encrypted request body, cookies, and response bodyCannot 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.