Understanding Reverse Proxy

Understanding Reverse Proxy

A Reverse proxy is one of the common and useful components in modern system design. It is essentially a type of proxy server that is present in front of web servers and forwards request from clients to servers. In this article, we’ll learn about reverse proxy, how it is different from forward proxy and explore the advantages of using it.

Preparing for Interviews? I highly recommend Mastering System Design course on Educative.


What is Reverse Proxy?

Before we deep dive into reverse proxy, it’s important to understand what does proxy means? In computer networks, A proxy server is an intermediary computer system that forwards client’s requests to different servers across the internet. The word proxy means “to act on behalf of another” and a proxy server acts on behalf of the user and forwards request to the server.

Now that we understand what proxy means let’s learn about reverse proxy. A reverse proxy server is a type of proxy server that is placed in front of one or more web servers and it directs client requests to the appropriate server. Though this brings in an additional network hop but it is commonly used due to lot of benefits that it brings to the overall architecture.

As a client, the reverse proxy simply appears as the web server and hides internal architecture to the users. Reverse proxy servers are implemented in popular open-source web servers such as Apache, Nginx, etc.


How does reverse proxy work?

A reverse proxy works in the following steps:

  • Client sends a request to the server.
  • Proxy server intercepts and accepts the client connection request.
  • Proxy server filters the request and forwards the original request to the appropriate server.
  • Web server returns the requested resources to the proxy server.
  • Proxy server returns the response back to the client.

Forward Proxy vs Reverse Proxy

There is a subtle but important difference between the two types of proxy. A forward proxy is a server that sits in front of the clients whereas reverse proxy sits in front of the web servers. A forward proxy is used to protect clients whereas reverse proxy is used to protect servers.

A forward proxy ensures that no origin server ever communicates directly with that specific client. While a reverse proxy sits in front of servers and ensures that no client ever communicates directly with the origin server.

Reverse vs Forward Proxy


Reverse Proxy vs Load Balancer

Both reverse proxy and load balancer are important components of computer systems. They do overlap in benefits where a reverse proxy can act as a load balancer along with lot of other features it provides.

Load balancing refers to process of efficiently distributing incoming network traffic across multiple servers. It is preferable to use a load balancer when you have multiple web servers. In case of a single server using a reverse proxy works well. Reverse proxy can also be useful in providing security, flexibility, and web acceleration.


Advantages of Reverse Proxy

Reverse proxy comes with a lot of benefits as it helps in increasing security and reliability of the system.

  • Load balancer - Reverse proxy can act as a load balancer distributing the request across multiple servers and not overloading a specific server with a lot of request.
  • Abstraction - It helps in abstracting characteristics about the origin server from the client. Thus, any changes to the server are transparent to the client.
  • Web acceleration - As all client requests pass through the proxy, it is a perfect point in a network to control traffic while also optimizing performance with compression, encryption offloading and caching.
  • Security - It can help in securing applications from web server attacks like DDoS. Basic HTTP header authentication and SSL termination can also be added to secure your applications at reverse proxy layer.
  • Caching - Reverse proxy can catch frequently accessed resources and serve them without making a call to web server. This helps in reducing the time it takes to generate a response and return it to the client. CDNs use this to reduce load on the web servers by caching static content.

Resources

Books for mastering system design


Liked the article? Consider supporting me ☕️ I hope you learned something new. Feel free to suggest improvements ✔️ I share regular updates and resources on Twitter. Let’s connect!

Keep exploring 🔎 Keep learning 🚀

Liked the content? Do support :)

Paypal - Mohit Khare
Buy me a coffee