Understanding Proxy, Forward Proxy, and Reverse Proxy in System Design

Arpit Bhayani

Arpit Bhayani

Mar 29, 2024 • 7 min read

Play

Understanding Proxy, Forward Proxy, and Reverse Proxy in System Design

In modern networking and distributed system design, the concept of an intermediary node—a proxy—is fundamental. A proxy is essentially a machine or cluster of machines positioned between two communicating systems (such as a client and a web server, or two distinct backend services) to mediate connections, abstract infrastructure complexities, and secure untrusted environments.

Proxies broadly fall into two architectural paradigms depending on whose behalf they act and what they abstract:

  1. Forward Proxy: Protects, abstracts, and mediates requests on behalf of the client.
  2. Reverse Proxy: Protects, abstracts, and mediates requests on behalf of the downstream server infrastructure.

Understanding where each proxy sits and the specific operational benefits it provides is critical when architecting scalable, resilient systems.


1. What is a Proxy?

At its core, a proxy acts as an intermediary for requests from clients seeking resources from other servers. Instead of the client connecting directly to the destination server, it connects to the proxy, which evaluates the request, optionally alters or caches it, and forwards it to the intended destination.

The primary motivation for introducing a proxy is abstraction—shielding internal system topologies, enforcing security parameters, or centralizing operational policies away from the endpoints.


2. Forward Proxy (Client-Side Abstraction)

A forward proxy sits in front of one or more clients (such as enterprise workstations, university lab machines, or mobile clients) and intercepts outbound traffic destined for external networks (like the public internet).

flowchart LR
    subgraph Private Network [Internal Corporate / College Network]
        ClientA[Client A]
        ClientB[Client B]
        ClientC[Client C]
        FP[Forward Proxy]
        ClientA --> FP
        ClientB --> FP
        ClientC --> FP
    end
    Internet((The Internet / LinkedIn / Web))
    FP -->|Single Source IP| Internet

Key Functions of a Forward Proxy

1. Identity Protection and IP Anonymity

The forward proxy masks client IP addresses. To external servers, every incoming connection originates from the single IP address (or pool of IPs) of the proxy machine rather than individual client workstations.

  • Real-world edge case (Rate Limiting Cascade): Because an entire network appears behind a single IP address, if one user triggers a downstream rate limiter or anti-scraping threshold (e.g., automated scraping of public profile data from services like LinkedIn), the target server may block the proxy’s IP address entirely. When this occurs, access is severed not just for the scraper, but for every user routing traffic through that forward proxy.

2. Policy Enforcement and Content Filtering

Forward proxies serve as centralized gatekeepers for organizational and regional access policies:

  • Organizational Firewalls: Corporate and educational networks configure forward proxies to inspect target URLs and protocols, blocking access to bandwidth-heavy or unauthorized domains (e.g., blocking torrent protocols, social networks, or unapproved tools).
  • Administrative Whitelisting: Certain enterprises maintain an allowlist-by-default posture where external sites must be evaluated and approved by an IT administrator before the proxy permits connections.
  • National and ISP-Level Filtering: Internet Service Providers (ISPs) implement forward proxies and firewalls to comply with national regulations, inspecting domain requests and dropping connections destined for blocked domains (such as country-wide blocks on TikTok).

3. Client-Side Request Caching

When multiple internal users request the same external static resources, a forward proxy can cache responses locally. Subsequent requests for the same resource are served directly from the proxy cache without traversing external transit links. In high-latency or constrained bandwidth environments (such as university intranets hosting shared documentation like JavaDocs), local proxy caching accelerates access and ensures availability even during external network outages.


3. Reverse Proxy (Server-Side Abstraction)

While a forward proxy hides the client from the server, a reverse proxy does the exact opposite: it sits in front of internal backend servers, exposing a single entry point to external clients while completely hiding downstream infrastructure.

flowchart LR
    Client[External Client / Public Internet]
    RP[Reverse Proxy / Gateway]
    
    subgraph Backend Infrastructure
        S1[Auth Service / Server 1]
        S2[Payment Service / Server 2]
        S3[Blog Service / Server 3]
    end
    
    Client -->|Public IP / Domain| RP
    RP -->|Path: /auth| S1
    RP -->|Path: /payments| S2
    RP -->|Path: /blog| S3

Key Functions of a Reverse Proxy

1. Load Balancing

A reverse proxy distributes incoming client traffic across a pool of backend servers using algorithms such as Round Robin, Least Connections, or IP Hash. By terminating client connections and managing upstream health checks, the reverse proxy ensures balanced resource utilization and prevents any single backend server from becoming overloaded.

  • Common tools: NGINX, HAProxy, Envoy.

2. Path-Based Routing (API Gateways)

Reverse proxies often function as API Gateways, inspecting HTTP request headers and paths to route traffic to the appropriate microservice:

  • Requests starting with /auth/* route to the Authentication Service.
  • Requests starting with /payments/* route to the Payment Service.
  • Common tools: Kong Gateway, Apache APISIX, Traefik.

3. Upstream Caching and Offloading

A reverse proxy can intercept reads for frequently accessed content. If a particular article, API response, or static asset is repeatedly queried, the reverse proxy caches the response body. Subsequent requests are returned immediately from the reverse proxy’s memory or local storage, saving the origin servers CPU cycles, memory, and database connections.

4. Infrastructure Abstraction and Elasticity

The reverse proxy decouples clients from server topology:

  • External clients only resolve the reverse proxy’s domain name (or Virtual IP).
  • The engineering team can dynamically scale the cluster up from 5 servers to 50 servers during high traffic spikes, or execute rolling deployments and decommission unhealthy machines.
  • Because downstream endpoints are completely abstracted, clients remain entirely agnostic to underlying cluster topology changes.

4. Advanced Reverse Proxies: Database Proxies

While reverse proxies are frequently discussed in the context of HTTP/HTTPS traffic (L7) and TCP streams (L4), the exact same principles apply directly to data tiers in the form of Database Proxies.

flowchart LR
    subgraph Application Tier
        App1[App Server 1]
        App2[App Server 2]
        App3[App Server 3]
    end
    
    DBP[Database Proxy / ProxySQL]
    
    subgraph Database Tier
        Primary[(Primary DB - Writes)]
        Replica1[(Replica DB 1 - Reads)]
        Replica2[(Replica DB 2 - Reads)]
    end
    
    App1 --> DBP
    App2 --> DBP
    App3 --> DBP
    
    DBP -->|Writes| Primary
    DBP -->|Reads| Replica1
    DBP -->|Reads| Replica2

An industry-standard example is ProxySQL (often utilized in MySQL deployments), which sits between application servers and the database tier.

Architectural Capabilities of DB Proxies

CapabilityMechanism & Value
Query CachingThe proxy parses incoming SQL statements. Identical SELECT queries can be returned immediately from the proxy cache, preventing repeated execution plans and disk/buffer I/O on the primary database engine.
Connection Pooling & MultiplexingApplications frequently spin up thousands of ephemeral connections. High connection concurrency exhausts database memory. A DB proxy maintains thousands of idle client connections while multiplexing them over a small, highly optimized pool of persistent connections to the database engine.
Topology & Sharding AbstractionThe proxy understands read/write splits and sharding topologies. It can automatically route INSERT/UPDATE operations to a primary node and balance SELECT operations across multiple read replicas without the application requiring distinct database connection strings. Changes in replication topologies or shard migrations remain invisible to the application layer.

5. Architectural Comparison: Forward vs. Reverse Proxy

AttributeForward ProxyReverse Proxy
Whom it representsThe ClientThe Server Infrastructure
Who is aware of itThe Client is configured to use it; the server is unaware.The Client connects directly to it as if it were the server; backends know it forwarded the request.
PlacementEdge of the client network / ISP edge.Edge of the server/backend network.
Primary ObjectivesPrivacy, anonymization, content filtering, local edge caching.Load balancing, security/DDoS protection, API routing, elasticity, caching.
Typical ImplementationsSquid, corporate enterprise firewalls, ISP middleboxes.NGINX, HAProxy, Envoy, Kong, ProxySQL, AWS ALB.

Summary

  • A Proxy is an intermediary system deployed to decouple systems, manage traffic, or abstract untrusted environments.
  • Forward Proxies sit in front of clients, protecting client anonymity, enforcing compliance policies, and reducing egress bandwidth consumption through shared local caches.
  • Reverse Proxies sit in front of backend applications and databases, abstracting operational elasticity, terminating TLS, balancing loads across servers, routing microservice endpoints, and pooling costly downstream resources.
Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses