Forward Proxies, Reverse Proxies & API Gateways
Definition
Proxy
- In plain English
- A proxy is a server that sits between a client and another server and passes messages along.
- Think of it like
- It is like an assistant who makes calls on someone's behalf.
Forward proxy
- In plain English
- A forward proxy acts for a group of clients, sending their requests out to the internet.
- Think of it like
- It is like a company mailroom that sends all staff letters under the company's name.
Reverse proxy
- In plain English
- A reverse proxy acts for a group of servers, receiving requests from the internet and passing them inside.
- Think of it like
- It is like hotel reception taking every visitor's request and forwarding it to the right room.
Why it exists
Five services check logins differently, and users see inconsistent failures. You need one shared place to enforce the entry rules.
A hospital also needs rules for outgoing staff browsing. The direction of the traffic determines which kind of proxy helps.
How it works
API gateway
- In plain English
- An API gateway is a reverse proxy for APIs that also does shared jobs such as checking logins, limiting request rates and routing to many services.
- Think of it like
- Like an airport security checkpoint every passenger passes before reaching any gate.
Rate limiting
- In plain English
- Rate limiting caps how many requests one client may send in a period of time.
- Think of it like
- Like a ride letting each guest go once per hour.
Caching and compression
- In plain English
- Caching reuses saved responses, while compression reduces the number of bytes needed to represent those responses.
- Think of it like
- It is like keeping spare handouts and folding each one into a smaller envelope.
Laptops send through a forward proxy to the internet. Internet clients reach servers through a reverse proxy in the second group.
| Role | Acts for | Typical jobs |
|---|---|---|
| Forward proxy | Clients | Control outgoing access |
| Reverse proxy | Servers | Receive requests, cache responses, compress data |
| Load balancer | Server group | Spread incoming traffic among healthy copies |
| API gateway | API services | Check logins, limit request rates, route paths |
Examples
Apply staff browsing rules
The hospital sends staff web browsing through a forward proxy. It blocks unsafe destinations and records access for later review.
The proxy represents hospital clients when they contact outside sites. Its rules belong to the organisation making those requests.
- Control which destinations staff devices reach.
- Record access according to the hospital’s policy.
The insight
A forward proxy enforces the client side’s rules.
Reuse the dock map
A reverse proxy refreshes the dock map every thirty seconds. In this measured workload, it answers 90% of map requests from its saved copy.
The remaining 10% reach the application servers. Compression reduces bytes sent, while the thirty-second refresh allows a short delay in map updates.
Riders request maps through the reverse proxy. It serves 90 percent from a saved map and forwards 10 percent to application servers.
The insight
Shared response reuse reduces repeated work across application servers.
Check entry rules once
An API gateway fronts booking, payment and timetable services. Each request carries a login token.
Login token
- In plain English
- A login token is a piece of data a service verifies as proof of a previous login.
- Think of it like
- It is like a wristband checked at an event entrance.
The gateway checks the token, limits each client’s request rate, and routes the path. Services still check permission for specific bookings.
The app contacts an API gateway, which routes booking, payment and timetable paths to their corresponding services.
The insight
Share login verification while keeping booking-specific permission checks close to the data.
Trade-offs
Pros
- Share HTTPS, response reuse and login verification.
- Hide internal service addresses.
Cons
- Add another forwarding step.
- Protect another component against failure.
- Keep booking rules from accumulating in the gateway.
Use when
- Use one domain for several services.
- Apply consistent entry rules across services.
Avoid when
- Avoid a redundant layer for one small service.
- Avoid moving every application decision into the gateway.
Quick check
Takeaways
- Forward proxies act for clients; reverse proxies act for servers.
- API gateways share entry checks, while many load balancers also provide reverse proxying.
- Keep shared entry rules at the front door and service-specific decisions within services.