Proxies are one of the critical components in designing large-scale distributed systems. We use them to decouple clients from servers and provide additional functionalities like caching, authentication, logging, etc. So let's move forward and discuss two types of proxies: Forward proxy and Reverse proxy. One of the key goals here is to understand their differences.
A forward proxy (also known as a proxy or proxy server) is a server that sits in front of a group of clients. When a client sends a request to a server, instead of going directly to the server, the request is routed to the forward proxy, which then forwards the request to the server.
In other words, when clients send requests to websites on the Internet, the forward proxy intercepts these requests and communicates with the servers on behalf of the clients (acting as an intermediary). This can help us to perform certain actions before the request reaches the original destination.
There are several reasons to use a forward proxy.
Reverse proxies are the exact opposite of forward proxies in terms of interaction pattern. A forward proxy acts on behalf of clients, and a reverse proxy acts on behalf of servers. So, unlike a forward proxy, which is used to protect clients, a reverse proxy is used to protect servers. To simplify the difference: A forward proxy ensures that no origin server ever communicates directly with that specific client. On the other hand, a reverse proxy ensures that no client ever communicates directly with that origin server.
When clients send requests to the server, the requests are intercepted by the reverse proxy. The reverse proxy will then send requests to and receive responses from the server. In other words, the client thinks it is directly interacting with the server, and the request goes to the reverse proxy without the client knowing about it (or does not know that some other server processed its request).
Let's take an example: Suppose we type "https://www.enjoyalgorithm.com" in our browser. Our browser makes a DNS query to get the IP address of enjoyalgorithm.com. If enjoyalgorithm.com uses a reverse proxy and configures it correctly, the DNS query will return the reverse proxy's IP address.
If you have any query or feedback, please write us at contact@enjoyalgorithms.com. Enjoy learning, Enjoy system design!