Forward Proxy vs Reverse Proxy and Who Sent the Error

A request can pass through a client-side proxy and a gateway in front of the destination. Follow the connection one step at a time to see where a proxy error came from.

Workstation and two network devices connected by patch cables to a server cabinet

Where forward and reverse proxies sit

A forward proxy accepts outgoing requests from a client such as a browser, a script or a CI worker. The client or its network selects the proxy. The forward proxy connects onward to the requested service, and that service typically sees the proxy’s outgoing IP as its network peer. A workplace might use a forward proxy to apply outbound network policy. A proxy tester uses one to check whether the configured route can reach a destination.

A reverse proxy accepts incoming requests for a site or API. The site operator points the public hostname at that gateway, which can handle TLS, serve cached responses or pass requests to an origin. A CDN often performs this role. One request can pass through both kinds of proxy. A cache miss could follow the full path below. HTTP intermediaries in RFC 9110

Request path
Client
  -> Forward proxy (client side)
  -> CDN or reverse proxy (destination side)
  -> Origin application

For example, a deployment script can connect through your organization’s outbound proxy to your public API hostname. The API’s CDN can then forward the request to your application. If you run a direct comparison without the outbound proxy, the public hostname still points to the CDN. Both tests can traverse the same destination-side gateway.

Check which request received the error

For HTTPS through an HTTP forward proxy, the client first sends CONNECT with the destination hostname and port. A successful response opens the tunnel. A conventional tunnel relays the bytes, and then the client negotiates TLS with the destination and sends the HTTP request inside that encrypted connection. Troubleshooting starts by identifying whether the reported code came back during the tunnel setup or in response to the request inside it. HTTP CONNECT semantics

What you seeWhere to look first
CONNECT returns 407The forward proxy is asking for proxy authentication. Check its authentication challenge, the credentials selected by your client and the provider’s access settings.
CONNECT returns 502 or 504The error arrived while opening the tunnel. Check whether the forward proxy or its upstream gateway can resolve and reach the destination host and port.
CONNECT succeeds, then the HTTPS request returns 502 or 504The error arrived through the tunnel. With ordinary end-to-end TLS, start with the destination’s edge or upstream services. The appliance that terminates TLS matters on networks that inspect traffic.

A 502 Bad Gateway indicates that a server acting as an intermediary received an invalid response from a server it contacted. A 504 Gateway Timeout indicates that it waited too long for the upstream response it needed. These codes describe what happened from the responding server’s point of view. Its logs can identify the upstream it was using. HTTP 407 · HTTP 502 · HTTP 504

Compare both routes to a known endpoint

Pick a stable HTTPS endpoint you own, such as a public /health path with a known status and body. Run both requests from the same authorized client and keep the destination URL and timeout identical. Make the direct request only where network policy allows it. On a network that requires a forward proxy, run the proxy test and ask the site operator for an approved comparison.

Replace both example addresses with your own. The first command requests the site directly. The second uses the specified proxy and limits the bypass list to localhost for this test, so the public destination goes through the proxy. These commands use a Unix-style shell. On Windows, run curl.exe and replace /dev/null with NUL.

curl --disable --noproxy "*" --silent --show-error --max-time 20 --output /dev/null --write-out "CONNECT=%{http_connect} destination=%{response_code}\n" "https://service.example/health"
curl --disable --noproxy "localhost" --proxy "http://proxy.example:8080" --silent --show-error --max-time 20 --output /dev/null --write-out "CONNECT=%{http_connect} destination=%{response_code}\n" "https://service.example/health"

The output shows the last response to CONNECT separately from the destination’s HTTP response. A value of 000 means cURL recorded no response code for that part of the transfer. It is expected for CONNECT on the direct request. If the destination field is 000 after a successful tunnel, read cURL’s error message for details such as a TLS failure or a client-side timeout. This check prints the statuses even when the server returns an HTTP error. cURL output variables · Proxy cURL tests and authentication

If you also want to confirm the outbound address for a successful request, use the same permitted route to open https://testmyproxies.com/api/my-ip and read the ip value. That result belongs to the IP-check request. Keep the health endpoint comparison for diagnosing your service.

Use proxy and origin logs to identify the failing hop

Suppose the direct test shows destination=200, and the proxy test shows CONNECT=504 destination=000. Start with the forward proxy’s tunnel log. Give its operator the destination host and port plus the time of the request. That helps them investigate the proxy’s resolver, its connection to the next hop and its timeout on the outbound route.

If both requests show destination=504 and the proxy test shows CONNECT=200, check the destination’s gateway log first. Match each request by timestamp and the request ID assigned at the edge, if available. Compare the upstream address, latency and status recorded by the edge with the origin’s access log. An error for one route only can still occur at the destination, since the two requests may reach different CDN locations or take different paths behind the gateway.

Use response headers and branded error pages as clues. A gateway can replace or omit a header, and several gateways can pass the same error along. Matching logs provide stronger evidence about where the status came from. Share the minimum relevant details with the responsible operator and redact credentials, cookies and private diagnostic data. How intermediaries use proxy headers · Diagnose TLS failures on a proxied route

All proxy testing guides · Open the proxy tester