What is the difference between a reverse proxy and a forward proxy?
A forward proxy sits in front of clients and makes requests on their behalf, hiding the client. A reverse proxy sits in front of servers and receives requests for them, hiding the servers.
Explain it simply
Imagine a hostel with a rule that students cannot leave. A forward proxy is a warden who goes out to buy things for students: outsiders see only the warden. A reverse proxy is a reception desk at a company: visitors talk to reception and never see which employee actually handles their request.
Forward proxy (client side): used by an office or school to filter websites, cache downloads or hide users' IPs. The server sees the proxy, not the client.
Reverse proxy (server side): used by a website to receive all incoming traffic. It can terminate TLS, cache responses, compress, rate limit, hide internal servers and balance load. The client sees only the proxy address.
Nginx, HAProxy and Envoy are common reverse proxies. A load balancer is essentially a reverse proxy focused on distributing traffic, and an API gateway is a reverse proxy with extra features like authentication.
Example
Same words, different direction:
Forward : Client -> [Proxy] -> Internet -> Server
server does not know the real client
Reverse : Client -> Internet -> [Proxy] -> Server A / Server B
client does not know which server answeredWhat to say in the interview
"A forward proxy represents the client and a reverse proxy represents the server. Reverse proxies give TLS termination, caching, load balancing and protection for backend servers, so almost every production web app has one in front."