A reverse proxy server is a server that sits in front of one or more web servers, receives requests from clients as if it were the website, and forwards them to the right backend server. Clients only ever talk to the proxy, so backends stay hidden. A reverse proxy typically handles TLS termination, load balancing, caching, compression and security filtering in one place, using tools such as NGINX, Caddy, Apache or a cloud load balancer.
Key takeaways
- A reverse proxy sits in front of your backends and forwards client requests to the right one.
- It centralizes TLS, load balancing, caching and security in one place, so backends stay simple.
- NGINX and Caddy are the most common self-hosted reverse proxies; cloud load balancers do the same job.
Open a popular website and you are probably not talking to the server that runs the app. You are talking to a reverse proxy — a front door that takes your request, decides which backend should handle it, and passes the answer back. It is one of the most useful patterns in web infrastructure, and it is simpler than it sounds.
What is a reverse proxy server?
A reverse proxy server is a server that sits in front of one or more web servers, receives requests from clients as if it were the website, and forwards them to the right backend. Clients only ever talk to the proxy; the backends stay hidden behind it.
The HTTP standard calls this kind of intermediary a gateway. RFC 9110 defines a gateway as an intermediary that acts as an origin server for the outbound connection. In practice, that means the proxy terminates the client's connection and opens its own connection to the backend.
Common reverse proxy software includes NGINX, Caddy, Apache with mod_proxy, HAProxy, Traefik, and cloud load balancers such as AWS Application Load Balancer and Cloudflare. NGINX powers about a third of identifiable web servers globally, according to web-server surveys cited in NGINX tutorials.
How does a reverse proxy work?
A reverse proxy follows the same four steps for every request. Understanding them makes troubleshooting far easier, because most proxy problems are a mistake in one of these steps.
- The client connects to the proxy. A browser resolves example.com and connects to the proxy's public IP on port 443. The proxy completes the TLS handshake.
- The proxy picks a backend. It reads the request and chooses a backend based on hostname, path, headers or a load-balancing policy.
- The proxy forwards the request. It opens its own connection to the backend, usually adding headers that say who the original client was.
- The proxy returns the response. It relays the backend's response to the browser, possibly caching or compressing it on the way.
What is the difference between a forward proxy and a reverse proxy?
The difference is who chose the proxy and whom it works for. A forward proxy sits in front of clients; a reverse proxy sits in front of servers.
| Forward proxy | Reverse proxy | |
|---|---|---|
| Sits in front of | Clients (users) | Servers (backends) |
| Configured by | The client or their network | The server owner |
| Client knows about it | Yes, usually | No, it is invisible |
| Typical uses | Web filtering, anonymity, caching | TLS, routing, load balancing, caching |
| Example | Corporate web filter | NGINX in front of a web app |
A forward proxy hides the client from the server. A reverse proxy hides the server from the client. Both can cache and filter, but they solve opposite problems.
Why would you use a reverse proxy?
A reverse proxy solves five problems at once, which is why it is so common. Each one alone would be a reason to use it; together they make it the default for most web deployments.
- TLS in one place. The proxy holds the certificate and handles HTTPS, so each app behind it can speak plain HTTP on a private interface.
- One public address for many services. Only one program can listen on ports 80 and 443, so the proxy routes by domain: app.example.com to port 3000, api.example.com to port 5000.
- Load balancing. The proxy can spread requests across several copies of an app and stop sending traffic to one that fails health checks.
- Caching and compression. The proxy can serve static files directly and compress responses, so backends do less work.
- Security in one place. Rate limits, authentication, security headers and access control can all be set at the proxy, with no changes to app code.
For a small business, the most common reason is the second one: several services on one server, with one clean HTTPS address for each.
How do you set up a reverse proxy with NGINX?
NGINX is the most common self-hosted reverse proxy. A minimal setup forwards everything on a domain to an app on port 8080 of the same machine.
Install NGINX, confirm your backend app is running, then create a server block with a proxy_pass directive pointing at the backend. The proxy_set_header lines matter: without them, your app sees every request as if it came from NGINX itself, from 127.0.0.1, over HTTP.
Here is a minimal NGINX reverse proxy configuration, using a fictional domain:
- proxy_pass http://127.0.0.1:8080; — the backend address. Use 127.0.0.1, not localhost, to avoid an IPv6 resolution mismatch.
- proxy_set_header Host $host; — passes the original hostname so the backend builds correct links.
- proxy_set_header X-Real-IP $remote_addr; — passes the client's real IP address.
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; — appends the client address to any existing forwarded-for chain.
- proxy_set_header X-Forwarded-Proto $scheme; — tells the backend whether the original request was HTTPS.
After editing the configuration, test it with nginx -t, then reload NGINX. If you see a 502 Bad Gateway error, the backend is usually not running, or it is listening on a different port. Check the NGINX error log at /var/log/nginx/error.log for the cause.
What about Caddy — is it simpler than NGINX?
Caddy is simpler for many small deployments, mainly because it handles HTTPS certificates automatically. A minimal Caddy reverse proxy can be one line: reverse_proxy localhost:8080 inside a site block for your domain.
Caddy requests a certificate from Let's Encrypt automatically when you give it a domain, and renews it without extra tooling. NGINX needs Certbot or a similar tool for the same job. For a single small service, Caddy is often the fastest way to a working HTTPS reverse proxy.
NGINX is still the better choice for complex setups, high traffic, or teams that already know it. Caddy is the better choice when you want HTTPS with the least configuration. Both are free and open source.
How does a reverse proxy improve security?
A reverse proxy improves security by hiding backends and centralizing controls. Backends can listen only on localhost, so they are never directly reachable from the internet. Only the proxy is exposed.
It also gives you one place to enforce security headers, rate limiting, authentication and IP allow-lists. If you need to block an abusive IP or add a header, you change the proxy, not every app.
There are limits. A reverse proxy is a single point of failure, and a misconfigured proxy can leak backend details through headers or error pages. Keep the proxy patched, turn off server version banners, and make sure backends do not trust X-Forwarded-For headers from anyone except the proxy.
For a wider view of protecting a public website, our guide to spear phishing covers the human side of attacks that a proxy cannot stop.
The free security headers checker shows whether your site sends the headers a proxy should set.
What mistakes should you avoid with a reverse proxy?
The most common mistake is forgetting the proxy_set_header lines, so the app sees the wrong host and IP. The next is the trailing slash in proxy_pass, which changes the path the backend receives.
Other mistakes include trusting X-Forwarded-For from the internet, which lets an attacker spoof their IP, and forgetting WebSocket support, which needs proxy_http_version 1.1 and Upgrade headers in NGINX. Always test login, redirects and WebSockets after a proxy change, not just the home page.
NGINX's official reverse proxy documentation explains proxy_pass and the headers a backend needs.
Cloudflare's reverse proxy guide covers the same pattern from a CDN perspective.
File transfers to a server behind a proxy still need a secure client. See our FileZilla alternatives for SFTP clients that work well here.
The bottom line
A reverse proxy is the front door for your web servers: one public address, TLS in one place, and backends hidden safely behind it. NGINX is the most common choice, Caddy is the simplest, and a cloud load balancer is the most managed option.
Start with one domain, one backend and HTTPS at the proxy, then add load balancing and caching when you need them. You can check that your site is serving HTTPS and the right headers with the free SSL checker.
Frequently asked questions
What is a reverse proxy server in simple terms?
A reverse proxy is a server that sits in front of your web servers and answers requests on their behalf. A visitor connects to the proxy, the proxy forwards the request to the right backend, and the backend's response goes back through the proxy. The visitor never talks to the backend directly.
What is the difference between a forward proxy and a reverse proxy?
A forward proxy sits in front of clients and works for them, such as a corporate web filter. A reverse proxy sits in front of servers and works for them, such as NGINX in front of a web app. The difference is who configured the proxy and whom it serves.
Is a reverse proxy the same as a load balancer?
No, but they overlap. A load balancer distributes traffic across several servers. A reverse proxy can do load balancing, but it also does routing, TLS termination, caching and security filtering. Many load balancers are also reverse proxies.
Do I need a reverse proxy for a small website?
Not always. A single small site on one server may not need one. You need a reverse proxy when you run several services on one server, want HTTPS in one place, need load balancing, or want to hide your backends from the internet.
Is a reverse proxy secure?
Yes, when configured correctly. It hides backend addresses, centralizes TLS, and gives you one place to add rate limiting, authentication and security headers. But it is also a single point of failure, so keep it patched, limit its attack surface, and back up its configuration.
What is NGINX reverse proxy?
NGINX as a reverse proxy is a configuration where NGINX receives HTTP requests and forwards them to a backend app, using the proxy_pass directive. It is one of the most widely used reverse proxy setups, and it also handles TLS, caching and load balancing.
Can a reverse proxy hide my server's IP address?
Yes. Clients only see the proxy's IP address, not the backend's. That helps protect backends from direct attacks, but it is not a complete anonymity solution — your proxy's address is still public, and DNS records can leak backend addresses if you are not careful.
What happens if a reverse proxy goes down?
If the proxy is the only front door, all backends behind it become unreachable, even if they are healthy. For important services, run two proxies with a floating IP or a cloud load balancer, so one failure does not take the whole site down.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against NGINX and Caddy documentation, Cloudflare's reverse proxy guide and RFC 9110.
How we write and fact-check →