SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
  • OSI Model
  • IP Address
  • TCP vs UDP
  • HTTP / HTTPS
  • DNS
  • Proxy vs Reverse Proxy
  • Checksums
  • HTTP/1.1 vs HTTP/2 vs HTTP/3
  • Cookies and CORS
  • Subnets, CIDR and NAT
  • Firewalls and VPN
  • Ports and Sockets
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Foundations/Networking

Proxy vs Reverse Proxy

A middle-man for clients, versus a middle-man for servers.

⏱ 11 min readBeginnerInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

A proxy is a middle-man server that passes requests and replies between two sides.

  • Forward proxy: stands in front of clients. The website sees the proxy, not the client.
  • Reverse proxy: stands in front of servers. The user sees the proxy, not the servers.
  • Quick memory trick: forward proxy hides the client. Reverse proxy hides the server.

02Concept: What is it?

Normally a client talks straight to a server. With a proxy, the client talks to the proxy, and the proxy talks to the server on its behalf. The word “proxy” means “someone who acts for another”.

Forward proxy
Works for the client
  • Sits near the clients (office, school, your device)
  • Client knows about it and is set up to use it
  • Website does not see the real client IP
  • Used for privacy, filtering and caching
Reverse proxy
Works for the server
  • Sits near the servers (the website’s side)
  • Client usually does not know it exists
  • Client does not see the real servers
  • Used for load balancing, TLS, caching and safety
Side by side
Forward proxy
💻Clients
→↓
🛡️Proxy
→↓
🌍Internet
Proxy protects the clients
Reverse proxy
🌍Internet
→↓
🚪Proxy
→↓
🖥️Servers
Proxy protects the servers

03Real-Life Example

🍵Two kinds of receptionist
Forward proxy = your personal assistant. You say, “Please call the bank for me.” The bank hears your assistant’s name and number, not yours. The assistant may even remember answers it already got.
Reverse proxy = the front desk of a big company. Visitors never walk into the offices. They tell the front desk what they need. The front desk sends them to the right person, checks their ID, and blocks troublemakers. Visitors never learn who sits where.
Real life
Software
Personal assistant
Forward proxy
Company front desk
Reverse proxy
You (the caller)
Client
Staff in the offices
Backend servers
Checking visitor ID
Authentication, TLS, firewall
Sending visitor to a free person
Load balancing
Answering common questions from a notice board
Caching

04Why Do We Need It?

Why use a forward proxy?

🕶️Privacy
Hide the client’s IP from websites.
🚧Control
A company can block sites or log what staff access.
⚡Cache
Many users asking for the same file get it fast from the proxy.

Why use a reverse proxy?

⚖️Load balancing
Share requests across many servers.
🔒TLS handled once
End HTTPS at the proxy, so servers stay simple.
🛡️Safety
Hide server IPs, block bad traffic, add rate limits.
⚡Cache and compress
Serve common pages quickly and send smaller replies.
🧭One entrance
Route /api to one service and /app to another.
🔧Easy changes
Add, remove or upgrade servers without users noticing.
A forward proxy helps the people who ask. A reverse proxy helps the servers that answer.

05Where Do We Use It?

PlaceKindWhat it does
Company or school networkForwardFilters websites, logs traffic, caches downloads
Privacy tools (VPN-like, anonymous browsing)ForwardHide your IP from sites
Web scrapers and testersForwardSend requests from different IPs or regions
Website front door (Nginx, HAProxy, Envoy)ReverseRoute, balance and secure traffic
CDN (Cloudflare, CloudFront, Akamai)ReverseA global reverse proxy with caching
API gatewayReverseAuth, rate limits and routing for APIs
Kubernetes ingressReverseRoutes outside traffic to services in a cluster

06Types / Parts / How It Works

What a reverse proxy can do

One entrance, many jobs
🧑Users
→↓
Reverse proxy
TLSHTTPS ends here
Securityfirewall, limits
Cachefast replies
Routing/api, /web
Balancepick a server
→↓
🖥️Web servers
⚙️API servers

Other words you will meet

NameMeaning
Transparent proxyClients do not need settings. The network sends traffic through it. Often used for filtering.
Anonymous / high-anonymity proxyHides the client IP, and tries to hide that a proxy is used.
SOCKS proxyA general proxy that passes any kind of traffic, not only web.
API gatewayA reverse proxy built for APIs: auth, rate limits, versions.
Load balancerA reverse proxy whose main job is to share traffic.
CDNMany reverse proxies placed around the world.
VisualizerForward vs reverse: who is hidden?Switch the proxy type, then step through one request.
Which proxy?
Office network
👩‍💻Alice10.0.0.5
↔not sent yet
🛡️Forward proxypublic IP 203.0.113.5
↔
🌍Website198.51.100.20
Step 1 of 4
Alice wants to open a website
Alice is in an office. The office network is set to send all web traffic through a forward proxy.
Who is hidden?
The client
The other side sees
Proxy IP
website sees 203.0.113.5
Set up by
Client side
company, school, user
A forward proxy stands in front of the clients. It speaks to the internet for them. Good for privacy, filtering and caching.

07How to Use It / Steps / Implementation

Putting a reverse proxy in front of your app

  1. 1
    Pick a proxy
    Nginx, HAProxy, Envoy, Traefik, or a cloud load balancer or CDN.
  2. 2
    Run your app on a private address
    Only the proxy should be reachable from outside.
  3. 3
    Point DNS to the proxy
    shop.com now leads to the proxy’s IP.
  4. 4
    Install the certificate on the proxy
    HTTPS ends here.
  5. 5
    Add the rules
    Which path goes to which server, rate limits, and cache rules.
  6. 6
    Pass the real client IP
    Send it in a header such as X-Forwarded-For so your app can still log it.
  7. 7
    Add health checks and more proxies
    So the proxy itself is not a single point of failure.
💡Trust X-Forwarded-For carefully
Anyone can send a fake header. Only trust it when it was added by your own proxy.

Using a forward proxy

  1. Set the proxy address in the browser, device or app (or use a network rule).
  2. Choose rules: which sites are allowed, and who may use it.
  3. Turn on caching for common downloads.
  4. Keep logs only as long as policy and law allow.

08Key Terms to Know

TermMeaning in easy words
ProxyA server that passes traffic between two sides on their behalf
Forward proxyActs for the clients
Reverse proxyActs for the servers
Origin serverThe real server behind the proxy that owns the content
Upstream / backendThe servers a reverse proxy sends traffic to
TLS terminationEnding the HTTPS tunnel at the proxy
X-Forwarded-ForA header that carries the original client IP
CachingKeeping a copy of a response to reuse
Rate limitingAllowing only a number of requests in a time window
Health checkA regular test to see if a backend is alive
GatewayAn entry point that routes and controls traffic
VPNA secure tunnel for all of a device’s traffic. Often confused with a proxy, but it works at the network level

09Pros, Cons and Trade-offs

Forward proxy
  • ✅ Hides client identity
  • ✅ Controls and logs access
  • ✅ Saves bandwidth with a cache
  • ⚠️ Single point to trust (it sees your traffic)
  • ⚠️ Can be slow or blocked
Reverse proxy
  • ✅ Hides and protects servers
  • ✅ Balances load and ends TLS
  • ✅ Easy to add or change servers
  • ⚠️ One more hop, a little delay
  • ⚠️ Can become a SPOF if not duplicated
ChoiceWe gainWe lose
Add a reverse proxySecurity, balance, one entranceOne more part to run and watch
Cache at the proxySpeed, less loadOld data may be shown
End TLS at the proxySimple servers, central certificatesInner traffic is plain unless you encrypt it again
Use many proxiesNo single point of failureMore cost and setup

10Common Problems and Mistakes

Common mistakes

  1. Mixing up the two. Remember: forward hides the client, reverse hides the server.
  2. One proxy only. If it dies, everything behind it is unreachable. Run at least two.
  3. Losing the client IP. Your app sees only the proxy’s IP unless you pass X-Forwarded-For.
  4. Letting people reach the backends directly. Then the proxy’s protection is skipped. Block outside access to them.
  5. Caching private pages. A cached “my account” page could be shown to another user. Use Cache-Control carefully.
  6. Forgetting timeouts. A slow backend can tie up the proxy. Set sensible timeouts.

Known problems

🚫502 / 504 errors
502 Bad Gateway: bad reply from the backend. 504 Gateway Timeout: the backend was too slow.
🎭Open proxy abuse
A forward proxy open to everyone is used by attackers. Require login.
👁️Privacy
The proxy owner can see unencrypted traffic. Trust it, or use HTTPS.
🐌Extra hop
Each proxy adds a little delay.

11Real-World Examples

🟩Nginx and HAProxy
Very common reverse proxies and load balancers.
☁️Cloudflare, CloudFront, Akamai
CDNs that act as reverse proxies in many cities.
🧩Envoy and service meshes
Proxies sit beside each microservice and handle retries, TLS and metrics.
☸️Kubernetes Ingress
A reverse proxy at the edge of a cluster.
🏢Corporate web gateways
Forward proxies that filter and log staff web use.
🎓Campus caches
Schools used forward caches to save bandwidth.
A typical modern website
🧑Users
→↓
🌍CDNreverse proxy 1
→↓
⚖️Load balancerreverse proxy 2
→↓
🚪API gatewayreverse proxy 3
→↓
🖥️Svc A
🖥️Svc B
Edge Balance Rules Your services
Several reverse proxies work together. Users only ever see the first one.

12Related Topics to Read Next

What are Load Balancers?→

A load balancer is a reverse proxy with a focus on sharing traffic.

HTTP / HTTPS→

Reverse proxies often end HTTPS for your servers.

IP Address→

Proxies change which IP the other side sees.

DNS→

DNS points your domain to the reverse proxy.

Single Point of Failure (SPOF)→

One proxy can be a SPOF, so use more than one.

Load Balancing Algorithms→

How a reverse proxy picks a backend.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • ✔Proxy: a middle-man that acts for someone else.
  • ✔Forward: in front of clients. Hides clients. Filters and caches.
  • ✔Reverse: in front of servers. Hides servers. Balances, secures, caches.
  • ✔Trick: forward hides the client, reverse hides the server.
  • ✔Tools: Nginx, HAProxy, Envoy, CDNs, API gateways.
  • ✔Pass the client IP with X-Forwarded-For, and trust it only from your own proxy.
  • ✔Run more than one reverse proxy so it is not a SPOF.
  • ✔One line: “A forward proxy speaks for clients; a reverse proxy speaks for servers.”
← Previous
DNS
Next →
Checksums