Make the right trade-off / CHAPTER 28
Forward proxies versus reverse proxies
Follow the company and store proxies to see whose connections they control and what the API must still check.
Builds on Polling, long polling, WebSockets, and server-sent events.
- Distinguish client-side and server-side proxy roles.
- Explain TLS termination and forwarded metadata.
- Identify privacy and failure boundaries.
01Whose requests does the proxy represent?
An employee's laptop visits an online store. Two intermediaries may be involved, with different owners:
- The company's forward proxy acts for the laptop. The company configures it to control which outside destinations employees may reach.
- The store's reverse proxy acts for the store. The store publishes its address, and the proxy chooses a private API server to handle the incoming request.
A proxy receives traffic and sends it onward. “Forward” and “reverse” describe whose traffic it represents, not mutually exclusive software products. The same software can perform different roles for different connections.
A proxy may cache, inspect or restrict traffic where its protocol and configuration permit. Its presence alone does not make traffic encrypted, anonymous or authorized. The company permitting a connection to the store does not decide whether the shopper may buy a particular item.
02Follow connections and trust boundaries
Follow the laptop's connection to the store:
- The laptop contacts its configured company proxy. It asks to connect to the store's destination.
- The company proxy may create an HTTPS tunnel. In that case it relays encrypted application bytes without reading the order body. It can still apply destination and connection rules. If it instead decrypts for inspection, the laptop must trust that setup and the company can read the content.
- The store's reverse proxy accepts the store's TLS connection. TLS encrypts bytes between its endpoints. Terminating TLS means decrypting them; this proxy can therefore read the request.
- The reverse proxy opens a new connection to an API worker. Protect and verify that connection separately when its network needs encryption. Encryption on the first connection does not extend automatically to the second.
- The API checks the user and purchase permission. Routing a request to the API is not authorization for its business operation.
The API may see the reverse proxy's network address rather than the laptop's. A forwarded header can report the original address, but the caller can forge incoming headers. The reverse proxy must replace untrusted values with observed connection information. The API accepts that information only from its configured proxies, not an alternate public route.
One shared company or household address still does not identify one person. Use verified user identity for account permissions.
03Worked example: a company laptop visits a store
Compare the two owners in the same purchase:
| Question | Company forward proxy | Store reverse proxy |
|---|---|---|
| Who configures the policy? | The company operating the clients. | The store operating the service. |
| What destination does it select? | An allowed outside service. | A healthy private API worker. |
| What does it control? | Outbound connection rules. | Incoming routing, TLS and selected common request rules. |
| What remains the API's job? | The store still verifies the user's action. | The selected API still checks purchase permission. |
Now inject a forged client-address header:
- An attacker claims to have an internal address.
- If the store blindly forwards that value, an API might apply a privileged internal policy.
- The reverse proxy replaces it with information from the actual connection. The API trusts the field only when the request came through the configured proxy chain.
- Block or equally protect an alternate API route; otherwise the attacker can bypass this checking path.
Finally, label every TLS connection in the drawing. Encrypting both laptop-to-proxy and proxy-to-API traffic still lets a terminating proxy read the content. Decide explicitly which operator is trusted with that readable information.
Forward proxies versus reverse proxies — decision flow
Follow the numbered arrows
- Employee laptop → Company forward proxyrequest an outside connection
- Company forward proxy → Store reverse proxyconnect to the allowed store
- Store reverse proxy → Store APIchoose a private API server
Trace the diagram in words
- The company proxy checks whether the laptop may reach the destination.
- The store proxy selects a server and replaces forged address headers with observed connection information.
- The API checks whether the verified user may perform this purchase.
04Use the proxy for a concrete responsibility
Choose each proxy for a stated responsibility:
- Forward proxy: use it when a client-side organization needs outbound control. Restrict who may use it and which destinations it can reach, so it cannot relay arbitrary traffic for strangers.
- Reverse proxy: use it for a stable public entry point, backend selection, TLS handling or common request controls. Prevent routes that skip mandatory rules.
- Private response caching: include the verified account and any response-changing fields in the cache key, or do not share the response. Never reuse one caller's private response for another merely because their URL matches.
- Availability: run sufficient proxy instances, enforce request deadlines and check whether an order worker can reach the database it needs. Stop sending it orders when that check fails; an open listening port alone does not show it can complete them.
- Configuration changes: release routing rules gradually and keep rollback. Several instances can all fail on the same bad shared rule.
Explain whose policy each proxy enforces, which request bytes it can read and what the API must still check. Those details make “the proxy protects traffic” concrete.
DRAW. CALCULATE. EXPLAIN.
Trace two proxy owners
20 minutes · guided practice
A mobile API receives requests through its reverse proxy, then calls a payment partner through an outbound forward proxy. The client supplies a forged original-address header. Describe routing, TLS, metadata handling and purchase authorization.
Compare the worked solution
- The incoming route is mobile client → service reverse proxy → API. The API's outgoing partner call uses API → outbound forward proxy → payment partner.
- The reverse proxy replaces the forged address header with observed connection information. The API trusts it only from its configured reverse proxy.
- The API authenticates the shopper and checks the purchase rule itself.
- Label every TLS endpoint. A tunnel relays encrypted bytes; an inspecting or terminating proxy can read them. Protect the onward connection separately.
- Restrict the forward proxy to approved callers and partner destinations, and verify the payment partner independently.
The checkboxes record your own assessment. The worked solution gives you a way to check the reasoning.
RETRIEVE BEFORE YOU REVEAL
Keep the important ideas.
Say the answer aloud, then turn the card over.
CARD 01Whose traffic do the two proxies represent?
- A company’s forward proxy controls its clients’ outbound connections.
- A store’s reverse proxy receives store traffic and selects private servers.
- The selected API still checks the user’s permission.
CARD 02What does TLS termination change?
- The terminating proxy decrypts and can read content.
- Its onward connection needs separate protection.
- Encrypting both connections still trusts the proxy with readable data.
CARD 03How should forwarded address headers be handled?
- The entry proxy replaces caller-supplied values with observed connection information.
- The API accepts it only from configured proxies.
- A shared IP address is not a verified person.
CHECK THE REASONING
Can you explain the choice?
Answer every question, then finish for an immediate score and an explanation for each answer. Aim for 80%, then revisit any gaps.
CLOSE THE LOOP
Explain it without the page.
Summarise the mechanism, one trade-off, and one failure mode. Then mark this chapter complete.