When it comes to networking, proxies and reverse proxies play a vital role in managing and securing network traffic. Both of them act as intermediaries between clients and servers, but they operate in different ways. In this blog post, we’ll discuss what proxies and reverse proxies are, how they work, and their benefits, along with some images to help illustrate the concepts.

What is a Proxy?

A forward proxy, often called a proxy, proxy server, or web proxy is a server that acts as an intermediary between a client and a server. When a client requests a resource from a server, the request first goes through the proxy server, which then forwards the request to the server. The server then responds to the proxy server, which in turn forwards the response back to the client.

The primary function of a proxy server is to act as a gateway between the client and server. It can perform several tasks, such as caching frequently requested resources, filtering web traffic, and providing anonymity to the client.

Photo by Ed Webster on Pexels.com

How Proxy Server Works

For example, let’s name 3 computers involved in a typical forward proxy communication:

  • A: This is a user’s home computer
  • B: This is a forward proxy server
  • C: This is a website’s origin server (where the website data is stored)

For a normal user in a standard internet world and also for a normal user, the computer A would directly reach out to computer C , with the client sending requests to the origin server and the origin server responding back to the client – computer A. When a forward proxy is in place, computer A will instead send requests to computer B, which will then forward the request to computer C. C will then send a response to B, which will forward the response back to A.

Now, you will get a question – why would anyone add this extra middleman or an extra machine in between their Internet activity? There are a few reasons one might want to use a forward proxy:

  • To avoid state or institutional browsing restrictions – Some governments, schools, and other organizations use firewalls to give their users access to a limited version of the Internet. A forward proxy can be used to get around these restrictions, as they let the user connect to the proxy rather than directly to the sites they are visiting.
  • To block access to certain content – Conversely, proxies can also be set up to block a group of users from accessing certain sites. For example, a school network might be configured to connect to the web through a proxy which enables content filtering rules, refusing to forward responses from Facebook and other social media sites.
  • To protect their identity online – In some cases, regular Internet users simply desire increased anonymity online, but in other cases, Internet users live in places where the government can impose serious consequences to political dissidents. Criticizing the government in a web forum or on social media can lead to fines or imprisonment for these users. If one of these dissidents uses a forward proxy to connect to a website where they post politically sensitive comments, the IP address used to post the comments will be harder to trace back to the dissident. Only the IP address of the proxy server will be visible.

What is a Reverse Proxy

A reverse proxy is a server that acts as an intermediary between the internet and a web server. When a client requests a resource, the request goes to the reverse proxy server, which then forwards the request to the web server. The server then responds to the reverse proxy server, which in turn forwards the response back to the client.

The primary function of a reverse proxy server is to distribute incoming traffic across multiple servers, improving performance and availability. It can also perform several tasks, such as load balancing, caching frequently requested resources, and providing security.

The difference between a forward and reverse proxy is subtle but important. A simplified way to sum it up would be to say that a forward proxy sits in front of a client and ensures that no origin server ever communicates directly with that specific client. On the other hand, a reverse proxy sits in front of an origin server and ensures that no client ever communicates directly with that origin server.

How Reverse Proxies Work

Let’s illustrate by naming the computers involved:

  • D: Any number of users’ home computers
  • E: This is a reverse proxy server
  • F: One or more origin servers

Typically all requests from D would go directly to F, and F would send responses directly to D. With a reverse proxy, all requests from D will go directly to E, and E will send its requests to and receive responses from F. E will then pass along the appropriate responses to D.

And why should we use Reverse Proxy

Below we outline some of the benefits of a reverse proxy:

  • Load balancing – Let’s say a popular website like Amazon, Hotstar, that gets millions of users every day, may not be able to handle all of its incoming site traffic with a single origin server. Instead, the site can be distributed among a pool of different servers, all handling requests for the same site. In this case, a reverse proxy can provide a load balancing solution which will distribute the incoming traffic evenly among the different servers to prevent any single server from becoming overloaded. In the event that a server fails completely, other servers can step up to handle the traffic.
  • Protection from targeted attacks – With a reverse proxy in place, a web site or service never needs to reveal the IP address of their origin server(s). This makes it much harder for attackers to leverage a targeted attack against them, such as a DDoS attack. Instead the attackers will only be able to target the reverse proxy, such as Cloudflare’s CDN, which will have tighter security and more resources to fend off a cyber attack.
  • Global Server Load Balancing (GSLB) – In this form of load balancing, a website can be distributed on several servers around the globe and the reverse proxy will send clients to the server that’s geographically closest to them. This decreases the distances that requests and responses need to travel, minimising load times.
  • Caching – A reverse proxy can also cache content, resulting in faster performance. For example, if a user in Paris visits a reverse-proxied website with web servers in Los Angeles, the user might actually connect to a local reverse proxy server in Paris, which will then have to communicate with an origin server in L.A. The proxy server can then cache (or temporarily save) the response data. Subsequent Parisian users who browse the site will then get the locally cached version from the Parisian reverse proxy server, resulting in much faster performance.
  • SSL encryption – Encrypting and decrypting SSL (or TLS) communications for each client can be computationally expensive for an origin server. A reverse proxy can be configured to decrypt all incoming requests and encrypt all outgoing responses, freeing up valuable resources on the origin server.

How they are different

Let’s see what is the difference between a forward and a reverse proxy

Forward ProxyReverse Proxy
Handles outgoing requests from the clientsHandles incoming requests to the server
Resides in front of the clientResides in front of the server
Provides anonymity to clientProvides anonymity to servers
Part of client side infraPart of server side infra
eg – PHP-Proxy, Squideg – NGINX, Istio