Proxy vs Reverse Proxy, and Where Each Sits in a Production Web App
A forward proxy protects clients, a reverse proxy protects servers. What a reverse proxy does in front of your app, and ten components around it.
On this page
Both are “a server in the middle” and the confusion ends with one question: who is the proxy working for? The one it works for is the one it protects, and the other side never sees it.
Forward proxy: working for the client
A forward proxy sits between user devices and the internet. Requests go to it, and it fetches on the client’s behalf.
laptop --> forward proxy --> internet site
(site sees the proxy, not the laptop)
Typical uses:
- Protect clients. Hide internal addresses, scan downloads, enforce company policy.
- Avoid restrictions. Appear to come from another network or region.
- Block content. Filter sites by category or policy in schools and offices.
- Cache. Share downloaded content among many users on one network.
Reverse proxy: working for the server
A reverse proxy accepts requests from clients, forwards them to backend servers and returns the results as if the proxy itself had produced them. Clients never learn the backends exist.
browser --> reverse proxy --> app server 1
\-> app server 2
(browser sees only the proxy)
| Forward proxy | Reverse proxy | |
|---|---|---|
| Sits in front of | Clients | Servers |
| Hides | The client from the site | The server from the client |
| Configured by | The client or its network | The site operator |
| Typical software | Squid, corporate gateways | Nginx, HAProxy, Envoy, cloud load balancers |
Behind a reverse proxy, your app sees the proxy’s IP. The real client address arrives in headers such as X-Forwarded-For. Anyone can send that header, so trust it only when set by your own proxy, and configure the app to read the right position in the list. Getting this wrong breaks rate limiting and audit logs.
A minimal reverse proxy block:
server {
listen 443 ssl;
server_name app.example.com;
location / {
proxy_pass http://app_backend;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Where it sits: ten components of a production web app
- 1. CI/CD pipeline
Builds, tests and deploys code to the server instances.
- 2. DNS
Resolves the hostname before any request reaches your infrastructure.
- 3. CDN
Serves static assets and cacheable pages from locations near users, absorbing most traffic.
- 4. Load balancer and reverse proxy
Receives what the CDN does not serve, terminates TLS and spreads requests across web application servers.
- 5. Application servers and APIs
Your code, talking to backend services over APIs.
- 6. Databases and caches
Durable storage, plus a distributed cache for hot reads.
- 7. Job queue and workers
Long-running or resource-heavy tasks leave the request path and run on workers.
- 8. Search service
A dedicated full-text engine such as Elasticsearch or Solr for search features.
- 9. Monitoring and logging
Metrics, logs and error tracking, with dashboards, so you can see what the system is doing.
- 10. Alerting
Notifies the right people through chat or paging when thresholds break.
Mistakes worth avoiding
| Mistake | Fix |
|---|---|
| One proxy, no redundancy | Run at least two, or use a managed balancer |
| Backends reachable directly from the internet | Firewall them so only the proxy can connect |
| Proxy timeouts shorter than the slowest legitimate request | Align proxy, app and upstream timeouts |
| Caching responses that vary by user | Set Vary and Cache-Control correctly, never cache authenticated pages by URL alone |
| No visibility at the proxy | Log request id, upstream chosen, status and latency |
Do
Terminate TLS at the proxy, pass client details in headers your app trusts only from the proxy, health-check upstreams, and give every request an id that follows it through all layers.
Don't
Expose application servers directly “just for debugging”, or forget the proxy when deciding where rate limits and authentication belong.
Takeaway
Forward proxies represent clients and reverse proxies represent servers. For most developers the reverse proxy is the important one: it is the front door that terminates TLS, balances load, caches and shields everything behind it. Put it in front of your application, around it put the other nine components, and give each a clear job.
Frequently asked questions
What is the difference between a forward proxy and a reverse proxy?
A forward proxy sits in front of clients and makes requests to the internet on their behalf, hiding clients from servers. A reverse proxy sits in front of servers and receives requests on their behalf, hiding servers from clients. The difference is whose identity is being protected.
What does a reverse proxy do for a web application?
It terminates TLS, balances load across application servers, caches static or cacheable responses, compresses output, enforces rate limits, serves error pages when backends are down and keeps backend servers off the public internet. Nginx and HAProxy are the common choices.
Is a load balancer the same as a reverse proxy?
A load balancer is a reverse proxy whose main job is distributing requests across a pool. Many reverse proxies do load balancing, and many load balancers do reverse-proxy tasks. The terms overlap, and layer 4 balancers that only forward connections are the case where they differ.
Why must a backend trust X-Forwarded-For carefully?
Behind a reverse proxy the backend sees the proxy's address, so the proxy passes the client address in headers such as X-Forwarded-For. Clients can forge that header too, so the backend should only trust it from known proxies and take the address the trusted proxy appended.



/* Comments */
Comments are offline right now — we reconnect automatically, nothing is lost.