A reverse proxy is a server that sits in front of your applications and takes every request from the internet on their behalf. Visitors talk only to the proxy, never to your apps directly.
What it does
When your browser asks for a page, the request lands on the reverse proxy first. The proxy looks at the request, usually its domain name and path, and forwards it to the right server on the private network. That server replies to the proxy, and the proxy replies to you. From outside, it looks like one website at one address, however many servers sit behind it.
Forward proxy or reverse proxy?
Both sit in the middle of a conversation, but they work for different sides.
- A forward proxy works for the client. A company or a VPN service runs one so that its users' requests go out through it, and websites see the proxy instead of the user.
- A reverse proxy works for the server. It sits next to your applications, and visitors see the proxy instead of your servers.
Why put one in front of your apps
- Routing: several apps can share one public address and port, and the proxy picks the app by domain or path.
- Load balancing: the proxy spreads requests across several copies of the same app, so no single server takes all the traffic.
- HTTPS: the proxy holds the TLS certificates and handles encryption, so the apps behind it don't each need their own setup. This is called TLS termination.
- Caching: it keeps copies of responses that rarely change and serves them without asking the app.
- Protection: your app servers stay off the public internet, and the proxy can block bad traffic or limit how fast one client sends requests. Cloudflare works this way, at a much larger scale.
Wondering how this was made? How we make these