0% completed
What is a Proxy Server?
On This Page
Forward Proxy
Collapsed Forwarding
Reverse Proxy
The Difference That Matters
A proxy is a piece of software or hardware that sits between a client and a server to facilitate the traffic flowing between them.
Nothing about that sentence says which side it stands next to, and that turns out to be the whole story. Stand it next to the clients and you get a forward proxy. Stand it next to the servers and you get a reverse proxy. They are built from the same idea and used for opposite reasons.
Forward Proxy
A forward proxy is a server that sits in front of one or more client machines and acts as an intermediary between those clients and the internet. It is also known as a proxy server, or simply a proxy.
When a client machine requests a resource on the internet, such as a web page or a file, the request goes to the forward proxy first. The forward proxy then forwards that request to the internet on behalf of the client, and returns the response to the client.
Because the request now arrives from the proxy rather than from the client, the destination server never sees who actually asked.
A forward proxy can hide the identity of the client from the server by sending requests on behalf of the client.
Forward proxies are typically used to cache data, filter requests, log requests, or transform requests. Transforming can mean adding or removing headers, encrypting or decrypting, or compressing a resource.
Collapsed Forwarding
A proxy coordinates requests from more than one client, and that position lets it optimize traffic in a way no single client could.
Suppose several nodes ask for the same data at the same time, and the data is not in cache. Sent directly, that is several separate reads of the same thing.
Routed through a proxy, those identical requests can be combined into one. The data is read from disk once, and the single result is returned to everyone who asked. This technique is called collapsed forwarding.
Reverse Proxy
A reverse proxy is a server that sits in front of one or more web servers and acts as an intermediary between those web servers and the internet.
When a client requests a resource, the request goes to the reverse proxy first. The reverse proxy forwards it to one of the web servers, which returns the response to the reverse proxy, and the reverse proxy returns the response to the client.
Contrary to the forward proxy, which hides the client's identity, a reverse proxy hides the server's identity.
Think about requesting something from facebook.com. The request is served by Facebook's reverse proxy server, which gets the response from one of the backend servers and returns it to the client. The client never learns which backend server actually produced the content.
A reverse proxy, just like a forward proxy, can be used for caching, load balancing, or routing requests to the appropriate servers.
The Difference That Matters
| Forward proxy | Reverse proxy | |
|---|---|---|
| Sits in front of | Client machines | Web servers |
| Whose identity it hides | The client's, from the server | The server's, from the client |
| Who it is deployed by | The side making the requests | The side serving the requests |
| Typical jobs | Caching, filtering, logging, transforming requests | Caching, load balancing, routing to the right server |
So the choice follows from who you are protecting. To protect the clients on your internal network, put them behind a forward proxy. To protect your servers, put them behind a reverse proxy.
💡 Interviewers ask this one because the names are confusing, not because the concept is hard. Answer it by naming the side, not the direction. "It sits with the clients, so the server sees the proxy instead of the user" is unambiguous, and it does not depend on remembering which of the two is called forward.
Key takeaway: A proxy sits between a client and a server to facilitate traffic. A forward proxy sits in front of client machines and hides the client's identity from the server. A reverse proxy sits in front of web servers and hides the server's identity from the client. Both can cache, and a proxy can also merge identical uncached requests into a single read, which is collapsed forwarding.
The next lesson, Uses of Proxies, goes through what people actually deploy proxies for.
karangoyanka
· 3 years ago
Does not api gateway performs same functionality as reverse proxy?
Vaishnavi Ainapure
· 5 months ago
An attacker can plan spoofing attack , sitting behind a forward proxy?
On This Page
Forward Proxy
Collapsed Forwarding
Reverse Proxy
The Difference That Matters