LearnastraTHE DESIGN COURSE

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.

Beginner1h of deliberate study10 questions

Builds on Polling, long polling, WebSockets, and server-sent events.

By the end, you can
  • 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:

  1. The laptop contacts its configured company proxy. It asks to connect to the store's destination.
  2. 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.
  3. 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.
  4. 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.
  5. 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:

  1. An attacker claims to have an internal address.
  2. If the store blindly forwards that value, an API might apply a privileged internal policy.
  3. 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.
  4. 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

Forward proxies versus reverse proxies — decision flowThe 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. Numbered arrows correspond to the connection key below. All connections are directional.Employee laptopUses the company’soutbound policyCompany forwardproxyChecks permittedoutside destinationsStore reverseproxyReceives requests forthe storeStore APIChecks the user’spurchase permission123Forward proxies versus reverse proxies — decision flowThe 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. Numbered arrows correspond to the connection key below. All connections are directional.Employee laptopUses the company’soutbound policyCompany forwardproxyChecks permittedoutside destinationsStore reverseproxyReceives requests forthe storeStore APIChecks the user’spurchase permission123Forward proxies versus reverse proxies — decision flowThe 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. Numbered arrows correspond to the connection key below. All connections are directional.Employee laptopUses the company’soutbound policyCompany forwardproxyChecks permittedoutside destinationsStore reverseproxyReceives requests forthe storeStore APIChecks the user’spurchase permission123

Follow the numbered arrows

  1. Employee laptop → Company forward proxyrequest an outside connection
  2. Company forward proxy → Store reverse proxyconnect to the allowed store
  3. Store reverse proxy → Store APIchoose a private API server
The company proxy controls outbound destinations. The store proxy chooses a backend, and that API checks the actual purchase permission.
Trace the diagram in words
  1. The company proxy checks whether the laptop may reach the destination.
  2. The store proxy selects a server and replaces forged address headers with observed connection information.
  3. 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.

Your self-check
Compare the worked solution
  1. The incoming route is mobile client → service reverse proxy → API. The API's outgoing partner call uses API → outbound forward proxy → payment partner.
  2. The reverse proxy replaces the forged address header with observed connection information. The API trusts it only from its configured reverse proxy.
  3. The API authenticates the shopper and checks the purchase rule itself.
  4. Label every TLS endpoint. A tunnel relays encrypted bytes; an inspecting or terminating proxy can read them. Protect the onward connection separately.
  5. 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?
  1. A company’s forward proxy controls its clients’ outbound connections.
  2. A store’s reverse proxy receives store traffic and selects private servers.
  3. The selected API still checks the user’s permission.
CARD 02What does TLS termination change?
  1. The terminating proxy decrypts and can read content.
  2. Its onward connection needs separate protection.
  3. Encrypting both connections still trusts the proxy with readable data.
CARD 03How should forwarded address headers be handled?
  1. The entry proxy replaces caller-supplied values with observed connection information.
  2. The API accepts it only from configured proxies.
  3. A shared IP address is not a verified person.
Practise this topic in the revision deck ↗

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.

1 / 10The laptop’s company filters external destinations. Which role is this?
2 / 10The store chooses one private API instance for an incoming request. Which role is this?
3 / 10The company proxy tunnels HTTPS without inspection. What can it generally do?
4 / 10The store reverse proxy terminates TLS. What must protect a backend hop over an untrusted network?
5 / 10An attacker supplies a privileged client-address header. Which handling is appropriate?
6 / 10What does a shared company IP establish about a caller?
7 / 10Why block an alternate public API route that skips required edge controls?
8 / 10When does one product qualify as both forward and reverse proxy?
9 / 10Which failure risk belongs in a reverse-proxy design?
10 / 10What restriction is especially important for a forward proxy?
0 of 10 answered

CLOSE THE LOOP

Explain it without the page.

Summarise the mechanism, one trade-off, and one failure mode. Then mark this chapter complete.

Go to the source