What is Reverse Proxy?
A server that sits in front of one or more backend servers, receives client requests on their behalf and forwards them, hiding the backends from clients.
Definition
A reverse proxy is a server that accepts requests from clients and forwards them to one or more backend servers, then returns the backends' responses as if it had produced them itself. MDN describes it as the opposite of a forward proxy: a forward proxy acts on behalf of clients and can hide their identity, while a reverse proxy acts on behalf of servers and can hide theirs. Because every request passes through it, a reverse proxy is the natural place to terminate TLS, route traffic by hostname or path to different services, balance load across several instances, cache or compress responses, add authentication, and enforce limits. Nginx, Caddy, Traefik, HAProxy, Envoy and Nginx Proxy Manager are common self-hosted reverse proxies, and CDNs and cloud load balancers do the same job as a service. In nginx the core directive is proxy_pass, which sets the protocol and address of the proxied server; by default nginx does not pass the client's original Host and Connection headers, so configurations usually set them explicitly along with forwarding headers such as X-Forwarded-For.
When to Use Reverse Proxy
Backends behind a reverse proxy see the proxy's IP address, not the client's, so pass the original details in headers (Forwarded, X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host) and configure the app to trust them only from the proxy. WebSockets and server-sent events need the proxy configured for upgrades and long-lived connections. In nginx, check proxy_http_version: 1.1 is the default only since nginx 1.29.7; older versions defaulted to 1.0.
Reverse Proxy in Practice
- One VPS runs Nginx Proxy Manager on ports 80 and 443; app.example.com is forwarded to a container on port 3000 and grafana.example.com to another on port 3001, each with its own Let's Encrypt certificate.
- An nginx server block with proxy_pass http://127.0.0.1:8000; puts a Python app server behind nginx, which handles TLS, gzip and static files.
- Traefik reads Docker labels and automatically routes api.example.com to whichever containers carry that label, balancing between replicas.
Common Mistakes
- Forgetting to forward the Host header and client IP, which breaks redirects, absolute URLs, logs and rate limiting in the backend.
- Letting the backend trust X-Forwarded-For from anyone, so clients can spoof their IP address; trust it only from the proxy's address.
- Exposing the backend port publicly as well, which lets traffic bypass the proxy's TLS, authentication and limits.
- Mixing up trailing slashes in proxy_pass URIs, which changes how nginx rewrites the request path.


