What is the difference between a forward proxy and a reverse proxy?
Understand forward proxy vs reverse proxy: who each represents, request direction, real use cases, and how Nginx works as a reverse proxy with examples.
Expected Interview Answer
A forward proxy sits in front of clients and forwards their outbound requests to the internet on their behalf, while a reverse proxy sits in front of servers and receives inbound requests from clients, forwarding them to the right backend.
A forward proxy hides and represents the client — it is what a browser or corporate network points to for outbound access, useful for filtering, caching, and anonymity. A reverse proxy hides and represents the server — clients think they are talking to one endpoint, while the proxy distributes traffic across backends, terminates TLS, caches responses, and enforces security. Nginx is most often used as a reverse proxy but can act as a forward proxy too.
- Clarifies whom the proxy represents (client vs server)
- Reverse proxy enables load balancing and TLS termination
- Forward proxy enables outbound filtering and anonymity
- Both add a caching and security layer
- Decouples clients from backend topology
AI Mentor Explanation
A forward proxy is like a team runner who fetches drinks and messages from outside the dressing room on behalf of the players, so the outside world only ever deals with the runner, not each player. A reverse proxy is like the on-field umpire who receives every appeal from the crowd and fielders and directs it to the correct decision-maker, so spectators never speak to individual officials directly — they only ever see the umpire out front.
Step-by-Step Explanation
Step 1
Identify who is being represented
A forward proxy acts for the client; a reverse proxy acts for the server.
Step 2
Trace request direction
Forward proxy handles outbound client traffic; reverse proxy handles inbound traffic to servers.
Step 3
Look at what is hidden
Forward proxy hides client identity from the internet; reverse proxy hides backend topology from clients.
Step 4
Map the Nginx role
Use proxy_pass with upstream blocks to make Nginx a reverse proxy in front of app servers.
Step 5
Layer in features
Add TLS termination, caching, load balancing, and rate limiting at the reverse proxy edge.
What Interviewer Expects
- Clear statement of whom each proxy represents
- Understanding of request direction (outbound vs inbound)
- Concrete use cases for each type
- Awareness that Nginx is primarily a reverse proxy
- Mention of TLS termination, caching and load balancing
Common Mistakes
- Swapping the definitions of forward and reverse proxy
- Thinking a reverse proxy hides the client rather than the server
- Assuming Nginx can only ever be a reverse proxy
- Confusing a reverse proxy with a plain load balancer only
- Ignoring the security and caching benefits of both
Best Answer (HR Friendly)
“A forward proxy stands in front of users and makes requests to the internet on their behalf, while a reverse proxy stands in front of servers and takes requests from users, then passes them to the right backend. In short, a forward proxy represents the client and a reverse proxy represents the server.”
Code Example
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://backend_app;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
upstream backend_app {
server 10.0.0.11:8080;
server 10.0.0.12:8080;
}Follow-up Questions
- How does Nginx terminate TLS at a reverse proxy?
- What headers should a reverse proxy forward to the backend?
- When would you choose a forward proxy in a corporate network?
- How does a reverse proxy differ from an API gateway?
- Can Nginx act as both a forward and reverse proxy at once?
MCQ Practice
1. A reverse proxy primarily represents which party?
A reverse proxy sits in front of servers and represents them to incoming clients, hiding the backend topology.
2. Which is a typical use of a forward proxy?
A forward proxy handles outbound client requests, making it ideal for filtering, caching, and anonymising internal user traffic.
3. Which Nginx directive routes requests to a backend as a reverse proxy?
proxy_pass forwards the incoming request to the specified upstream server, the core of Nginx reverse proxying.
Flash Cards
Who does a forward proxy represent? — The client — it forwards outbound requests to the internet on the client's behalf.
Who does a reverse proxy represent? — The server — it receives inbound requests and forwards them to backends.
Primary Nginx role — Nginx is most commonly deployed as a reverse proxy in front of application servers.
Reverse proxy extras — TLS termination, load balancing, caching, compression and rate limiting at the edge.