Proxy Server vs Reverse Proxy Server | Explained with real-life example

Proxy Server vs Reverse Proxy Server | Explained with real-life example

Proxy and reverse proxy servers are common terms in backend engineering and computer networking. You may have heard of them before, but do you know what they mean and how they differ?

In this article, I will use a simple real-life example to explain the concept of proxy in the simplest way possible.

Analogy

In our childhood, whenever we wanted anything, we always went to our parents and asked for it. And then it was up to parents to decide if it was a legitimate request to be fulfilled or not.

Storyboard Brainstorm Presentation (2).png

Suppose you wanted a toy. You always thought that your parents are the one who will fulfil your request. That was actually true, as your parents went outside (to market) to get the stuff. They never let the outside world come in contact with you because you were too small. Thats how our parents shielded us from the outside world till the time we were matured enough to handle it by ourselves.

Simply, just correlate this example with a proxy server.

In simple words, proxy is an act that someone else does on your behalf. (Eg - Proxy attendance in college). Proxy is an interface between you and the outside world.

Proxy Server

proxy-server-1024x649.png

So basically, proxy works for the safety of the client. Whenever we are making any request from our local machine to hit a server which is present outside the network (from intranet to internet), proxy it the interface through which we send the request and it fetches the data from the internet on our behalf.

Use cases of Proxy

  1. Caching - It is a very popular use case of proxy server. It saves bandwidth by caching the content and serving it back to the client instead of going to the internet every time.

  2. Anonymity - Proxy talks to the server so the final destination (server) does not know from where the request is actually coming from.

  3. Security - It acts as a firewall. Multiple client machines can talk to a centralized proxy server. It helps organizations and ISPs, block or filter the bad requests which could impact client machines sitting inside the network.

  4. Encryption & Decryption - Proxy can encrypt and hide (mask) IP address and sensitive data going through the request. It only sends it in a way where you can not be discovered back.

  5. Logging - Logging can help caching the pages which are being visited often.

  6. Microservices - This is one of the latest and very interesting use case of proxy. There are several types of proxy such as sidecar proxy, HTTP proxy, TCP proxy etc. We can deploy proxy next to our application and it can take care of all the networking stuff.

For example, we are sending a HTTP request from our microservice, and our sidecar proxy can upgrade it to a newer protocol as HTTP2 or HTTP3.

Reverse Proxy Server

As the name says, its just reverse of proxy and that's why it's very confusing. The main concept and the difference is that, instead of doing it from the client side (as it was in proxy), it does it from the server side.

FreeReverseProxy.jpg

A reverse proxy server does the opposite of a regular proxy server. It protects the server instead of the client. When an internet request wants to access a server in our network, it goes through the reverse proxy server first. The reverse proxy server then decides which server to forward the request to, without exposing our servers.

Picture a reverse proxy as your trusted friend navigating the busy streets of Kathmandu for you. You're craving momo from your favorite spot, but instead of braving the traffic and crowds yourself, your friend goes, places the order, and brings the delicious dumplings right to your doorstep. In the online world, a reverse proxy does something similar for websites—it handles the complex stuff, like managing traffic and securing connections, so the website can focus on delivering content without getting overwhelmed. It's like having a reliable friend making sure you get what you want, hassle-free!

Advantages of Reverse Proxy server -

Almost all the benefits we have from proxy server including caching, security etc, all are there in reverse proxy too. Here we have some additional benefits.

  1. Load balancing A reverse proxy can distribute the load among multiple servers and compress the request size, which improves the overall performance.

  2. Ingress - Kubernetes and microservice architecture use a request-based routing mechanism. This means that each request is directed to the specific service that can handle it. For example, if a request comes for a picture API, it is routed to the corresponding service. In this way, Kubernetes and microservice architecture act as routers.

  3. Canary Development: A canary deployment is a way of testing a new feature on a small subset of users before rolling it out to everyone. For example, YouTube might want to try showing a randomly generated thumbnail for 10% of its requests. This can be achieved by using a reverse proxy that redirects some traffic to the new version of the service.

Thanks for reading!