Proxy Servers - A Web Developer's Perspective

Web Development May 12, 2023

Introduction

In software development, Proxy is defined as an intermediary server or software component that acts as a gateway between two or more systems. It facilitates communication between these systems by forwarding requests and responses between them.

Benefits of using Proxy server

While the types of proxies vary based on usage. There are few benefits that all of these have in common. Some of these are listed here:

  1. Security: By acting as a gateway between the client and server, proxies can provide an additional layer of security by filtering and blocking malicious traffic, encrypting sensitive data, and authenticating and authorizing access to backend services.
  2. Scalability: Proxies can improve the scalability of web applications by distributing incoming traffic across multiple backend services, caching frequently accessed content, and reducing the load on individual backend services.
  3. Simplified architecture: By hiding the specific details of the backend services from the client, proxies can simplify the architecture of web applications and make it easier to change or update backend services without affecting the client.

Types of Proxy

Generally speaking Proxies can be classified into many types based on the purpose of usage. Some of these are:

  1. Forward Proxy: A forward proxy, also known as a web proxy, is a proxy that sits between a client and the internet. It intercepts requests from the client and forwards them to the internet, acting as an intermediary between the client and the web server. This type of proxy is commonly used to improve security and privacy, as it can mask the client's IP address and protect their identity.
  2. Reverse Proxy: A reverse proxy is a server that sits between the internet and a web server. It intercepts incoming requests and forwards them to the appropriate web server, acting as an intermediary between the internet and the web server. This type of proxy is commonly used to improve scalability and reliability, as it can distribute incoming requests across multiple web servers and balance the load.
  3. Open Proxy: An open proxy is a proxy server that is accessible to anyone on the internet. It can be used by anyone to bypass internet filters, access restricted content, or hide their identity. This type of proxy is often used for malicious purposes, such as spamming or hacking, and is generally not recommended.
  4. Transparent Proxy: A transparent proxy is a proxy server that intercepts requests without modifying them. It is often used to cache frequently accessed content and improve performance, as well as to filter traffic and block access to unauthorized websites or services.
  5. Anonymous Proxy: An anonymous proxy is a proxy server that hides the client's IP address and protects their identity. It is commonly used to bypass internet filters and access restricted content, as well as to improve security and privacy.
  6. SSL Proxy: An SSL proxy is a proxy server that intercepts SSL/TLS traffic and decrypts it before forwarding it to the web server. It is commonly used to filter and monitor encrypted traffic for security purposes.

As we have discussed, there are different types of proxies that can be used for different purposes. Today, we are going to learn more about the topic from a web development point of view. Forward proxy and reverse proxy are the most relevant ones in this regard. Hence we will discuss these in more detail:

Forward Proxy

A common example of a forward proxy is a proxy server used by employees in a company to access the internet. The proxy server sits between the employee's computer and the internet, intercepting all requests for internet resources such as websites or APIs. At Halodoc we use forward proxies to get these benefits:

  1. Accessing restricted geo-locations:  Forward proxy servers come in handy to access geo-restricted contents.
  2. Ensuring anonymity:  A forward proxy server acts as an additional safety layer that hides the web server’s real IP address by using one of its own. This is the reason why using forward proxy servers ensures higher levels of anonymity and security.
  3. Web scraping: Companies usually gather data to improve their marketing, pricing, and other business strategies. Web scraping helps companies to stay competitive in the market.
  4. Control & monitoring:  Forward proxies can also be used to control and monitor internet usage, create and manage social media accounts, and much more.
Forward proxy is often considered same as VPN or Virtual Private Network from the top level. But these are some what different. One of the major difference between the two is that all the traffic entering in to a VPN are encrypted. This adds an additional layer of security.
Forward Proxy Server

Reverse Proxy

As discussed earlier, reverse proxy is a server that sits between the client and server, receiving incoming requests from the client and forwarding them to the appropriate server based on the request's URL. Some of the common benefits of reverse proxy are:

  1. Load balancing: A reverse proxy can distribute incoming traffic across multiple servers, which helps to distribute the load and prevent any one server from becoming overwhelmed.
  2. Improved performance: A reverse proxy can cache frequently accessed content, which reduces the number of requests that need to be made to the backend servers. This can improve the response time and reduce the load on the backend servers.
  3. SSL termination: A reverse proxy can terminate SSL connections, which offloads the SSL processing from the backend servers and reduces their workload.
  4. Security: A reverse proxy can act as a barrier between the internet and the backend servers, which provides an additional layer of security. The reverse proxy can also filter out malicious traffic and prevent DDoS attacks.
  5. Simplified architecture: A reverse proxy can simplify the architecture of a web application by allowing multiple backend servers to be accessed through a single endpoint. This can make it easier to manage and scale the system.
  6. Support for multiple applications: A reverse proxy can be configured to route traffic to different applications based on the URL path or domain name. This allows multiple applications to be hosted on the same server and accessed through a single endpoint.

In addition, a reverse proxy can help in implementing the BFF (Backend For Frontend) design pattern. In the BFF pattern, each frontend client (such as a mobile app or web app) has its own dedicated backend API, which serves as a gateway to the backend services. This allows the frontend client to access the backend services in a way that is optimized for its specific needs.

By using a reverse proxy in conjunction with the BFF pattern, we can create a scalable and resilient system that provides a customized experience for each frontend client.

Reverse Proxy and API Gateway

A reverse proxy is often confused with the API Gateway. While these are similar in many ways and are sometimes used interchangeably, but they are not the same thing.

An API Gateway is a specialized type of Reverse Proxy that is designed specifically for managing API requests. Like a Reverse Proxy, an API Gateway sits between the client and server, receiving incoming requests from the client and forwarding them to the appropriate backend services based on the request's URL. However, an API Gateway provides additional functionality beyond simple routing. It can perform functions such as authentication and authorization, rate limiting, protocol translation, and API versioning. It also often provides an API management interface for developers to monitor and manage their APIs.

Halodoc and Proxy Servers

In order make our applications secure, reliable, and performant, we implement Proxy servers wherever and when ever it is required. Reverse proxies like NGINX, Apache Tomcat Server and HAProxy are used in our applications.

One of our application developed on the MFE or Micro Frontend Architecture in Angular framework uses NGINX as a reverse proxy server. The task of NGINX as a reverse proxy here is to route the client request to the appropriate MFE. It is also used to cache some of the informations that is required for a user to have seemless experience.

Halodoc Architecture using Reverse Proxy

We also have an inbuilt reverse proxy built on BFF pattern. It acts an API gateway. It also helps to authorise and authenticate the requests that are sent to the backend servers. Since, we follow MicroServices Architecture for the backend, it also helps to redirect the requests to the respective micro service.

Conclusion

In order to build a scalable, reliable and secure web applications like we have at Halodoc, proxy servers are indispensable. Also, as web developers, we should be aware of the different types of proxies to get the optimum benefits. Here in this blog we discussed the types and benefits of proxy.

Join us

Scalability, reliability and maintainability are the three pillars that govern what we build at Halodoc Tech. We are actively looking for engineers at all levels and if solving hard problems with challenging requirements is your forte, please reach out to us with your resumé at careers.india@halodoc.com.

About Halodoc

Halodoc is the number 1 all around Healthcare application in Indonesia. Our mission is to simplify and bring quality healthcare across Indonesia, from Sabang to Merauke. We connect 20,000+ doctors with patients in need through our Tele-consultation service. We partner with 3500+ pharmacies in 100+ cities to bring medicine to your doorstep. We've also partnered with Indonesia's largest lab provider to provide lab home services, and to top it off we have recently launched a premium appointment service that partners with 500+ hospitals that allow patients to book a doctor appointment inside our application. We are extremely fortunate to be trusted by our investors, such as the Bill & Melinda Gates Foundation, Singtel, UOB Ventures, Allianz, GoJek, Astra, Temasek and many more. We recently closed our Series C round and In total have raised around USD$180 million for our mission. Our team works tirelessly to make sure that we create the best healthcare solution personalised for all of our patient's needs, and are continuously on a path to simplify healthcare for Indonesia.






Nivedita Rashmi

Frontend Developer at Halodoc