A reverse proxy is a server or load balancer that sits between client devices (such as web browsers or APIs) and a web server, forwarding client requests onward and then returning the server's responses to the clients. 

This intermediary between users and web servers works on behalf of the servers and not on behalf of the clients like a forward proxy would. It ensures that no client can communicate directly with a backend server.

How does a reverse proxy work?

haproxy-reverse-proxy-diagram

A reverse proxy works in the following way:

  1. A client sends a request while attempting to access a web app or API. The reverse proxy receives this request. 

  2. The reverse proxy forwards that request to the appropriate web server. 

    • A reverse proxy will often filter out invalid or harmful requests, forwarding only legitimate requests.

    • A reverse proxy functioning as a load balancer will determine the appropriate web server using load balancing algorithms and health checks.

  3. The web server processes the request and generates a response. 

  4. The reverse proxy receives this server response and forwards it to the client. The server can bypass the proxy, however, when direct server return is enabled.

Why are reverse proxies useful?

A reverse proxy provides numerous performance, security, and scalability enhancements for web applications and APIs. These can include the following:

  • Load balancing Reverse proxies that also function as load balancers can distribute incoming requests (sometimes millions per second) across multiple servers to prevent any one web server from getting overwhelmed. When a server degrades or fails, the proxy will send traffic to another working server to prevent service disruptions. 

  • Filtering & firewall protection – Reverse proxies often ship with customizable rulesets, weights, measures, and Web Application Firewall (WAF) implementations to stop malicious traffic and abuse. 

  • Caching – Reverse proxies can store copies of server responses and quickly serve them to clients without forwarding redundant server requests.

  • SSL termination Proxies can handle SSL/TLS encryption and decryption, a resource-intensive task that'd otherwise be left to the web server.

Does HAProxy offer reverse proxying?

Yes! HAProxy is the world's fastest software load balancer, and reverse proxy functionality is a key part of that equation. HAProxy acts as a traffic controller for incoming client requests and information before they hit application servers. 

Not only does HAProxy determine how requests are routed, but it also adds advanced security layers to prevent malicious traffic from causing an impact. For organizations seeking improved application performance and infrastructure protection, HAProxy is second to none.