# Reverse Proxies and API Gateways

> Understand forward vs reverse proxies and what an API gateway adds: routing, auth, rate limiting, request shaping and a single entry point. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/system-design/proxies-and-api-gateways
Last updated: 2026-11-28

Understand forward vs reverse proxies and what an API gateway adds: routing, auth, rate limiting, request shaping and a single entry point.

Intermediate · about 2 hours · difficulty 2/5

Learn first: [Load Balancing](https://www.internhack.in/roadmaps/tracks/system-design/load-balancing)

A **forward proxy** acts on behalf of clients (a corporate proxy that filters browsing). A **reverse proxy** acts on behalf of servers: clients talk to it, and it forwards to backends. Load balancers are a kind of reverse proxy; so are API gateways.

### What a reverse proxy gives you

- TLS termination in one place.
- Compression, response caching and serving static files.
- Hiding internal topology; backends are not exposed to the internet.
- Buffering slow clients so app servers are not tied up.

### API gateway responsibilities

In a system with many services, an **API gateway** is the single front door:

- **Routing**: /orders to the order service, /payments to the payment service.
- **Authentication**: validate JWTs or API keys once, pass identity downstream.
- **Rate limiting and quotas** per user, API key or IP.
- **Request and response transformation**, API versioning and aggregation.
- **Observability**: one place for access logs, metrics and trace IDs.

Popular choices: Kong, AWS API Gateway, Envoy based gateways, Nginx, and Spring Cloud Gateway in Java shops.

### Backend for Frontend (BFF)

Mobile and web clients often need differently shaped data. A **BFF** is a thin gateway per client type that aggregates calls, so the Android app makes one request instead of six.

### Pitfalls

- Putting business logic in the gateway until it becomes a hidden monolith.
- A single gateway cluster with no redundancy: it is now your biggest single point of failure.
- Adding a gateway hop for a two-service system that does not need it.

You are ready to move on when you can sketch where the gateway sits in a food delivery app, list what it should and should not do, and explain how it differs from a plain load balancer.

## Key concepts

- **Forward vs reverse proxy**
- **TLS termination**
- **API gateway routing and auth**
- **Rate limiting at the edge**
- **Backend for Frontend (BFF)**
- **Kong, Envoy, AWS API Gateway**

## Mini project

Put Nginx or Kong in front of two small services, route by path, terminate TLS with a self-signed certificate, and add a per-IP rate limit. Document the config and what happens when one backend is down.

## Check yourself

List three responsibilities that belong in an API gateway and two that should stay inside the services, with a reason for each.

## Free resources

- [What is a reverse proxy?](https://www.cloudflare.com/learning/cdn/glossary/reverse-proxy/) (Cloudflare)
- [API gateway pattern](https://microservices.io/patterns/apigateway.html) (microservices.io)
- [Kong Gateway documentation](https://docs.konghq.com/) (Kong)

Previous: [Load Balancing](https://www.internhack.in/roadmaps/tracks/system-design/load-balancing) · Next: [Relational Databases and SQL for Design](https://www.internhack.in/roadmaps/tracks/system-design/relational-databases)

## More in DNS, CDNs, Load Balancers and Gateways

- [DNS in System Design](https://www.internhack.in/roadmaps/tracks/system-design/dns)
- [Content Delivery Networks (CDNs)](https://www.internhack.in/roadmaps/tracks/system-design/cdn)
- [Load Balancing](https://www.internhack.in/roadmaps/tracks/system-design/load-balancing)
- [Reverse Proxies and API Gateways](https://www.internhack.in/roadmaps/tracks/system-design/proxies-and-api-gateways)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [System Design Roadmap](https://www.internhack.in/roadmaps/tracks/system-design)
