Proxy & Reverse Proxy

Proxy & Reverse Proxy

In our day to day life, we hear this term proxy a lot. So, let's try to understand the actual definition and need of using a proxy.

Proxy

As per english dictionary, a proxy is an agency, individual who acts as a substitute for another or it is someone who does some work on behalf of us.

Reminds me of college days, when I asked my friends to put a proxy attendance (an attendance on my behalf on my absence) :P Yes, so in a software world this is not something very different.

A proxy server is an intermidiary piece of hardware/software(interface) that sits between client(us) and backend-server(outside world) and does the actual talking or interaction with the server. It receives the requests from the clients and relays them to the origin servers.

Proxy.drawio.png

Proxies are used for the following:

  • Filter requests : Filters and selectively send/block the client requests before sending to server.
  • Log requests : Logs requests for monitoring to ensure restriction/security.
  • Client Security : Saves from phishing attack, viruses, malwares by acting as a firewall.
  • Cache requests : Caches static data, fulfilling client request without round-trip to server.
  • Encryption/Decryption : Encrypts(masks) ip and other sensitive data, when sending data over the request to server, not letting know the server where the request is coming from.
  • Compression : Collapse similar data access requests into one requests and return single result to client.

Reverse Proxy

Now from the name, can you guess what would be a reverse proxy then ?

Yes, I think you might have guessed it right. A reverse proxy acts as a proxy to the server instead of a client (for requests coming in).

Whenever a request comes from a client(outside world), a reverse proxy decides which server it should send the incoming request.

Reverse_Proxy.drawio.png

Reverse Proxies are used for the following:

  • Server Security : Saves the server from cyber attack/bots/hackers.
  • Rate limiting : Saves the server from DDOS attack and also allow fixed number of requests to be entertained by sever based on the rate limit of the service.
  • Encryption/Decryption : Encrypts(masks) ip and other sensitive data, when sending response to client, not letting know the client where the response is coming from.
  • Load Balancing : In case of multiple requests coming from several client, reverse proxy evenly distributes the load(incoming requests) across the servers.
  • API Gateway : In case of microservice architecture, reverse proxy acts as an API Gateway to sort out destination application/services necessary to handle incoming requests.
  • Caching : Caches responses from server, fulfilling client request without round-trip to server.
  • Compression : Collapses/reduces amount of data packet/request flowing across network.

Conclusion

So as we saw, the usecase and working of a proxy and a reverse proxy server are pretty similar with major difference/advantage of a reverse proxy being load balancing. In the upcoming articles we will deep dive into load balancing and methods of load balancing. Till then, stay tuned and thankyou for your time.