A reverse proxy protects web servers from attacks and can provide performance and reliability benefits. Learn more about forward and reverse proxies.
What is a proxy server?
A forward proxy, often called a proxy, proxy server, or web proxy, is a server that sits in front of a group of client machines. When those computers request sites and services on the Internet, the proxy server intercepts those requests and then communicates with web servers on behalf of those clients, like a middleman.
For example, let’s name 3 computers involved in a typical forward proxy communication:
- A: This is a user’s home computer
- B: This is a forward proxy server
- C: This is a website’s origin server (where the website data is stored)
In standard Internet communication, computer A would reach out directly to computer C, with the client sending requests to the origin server and the origin server responding to the client. When a forward proxy is in place, A will instead send requests to B, which will then forward the request to C. C will then send a response to B, which will forward the response back to A.
Why would anyone add this extra middleman to their Internet activity? There are a few reasons one might want to use a forward proxy:
- To avoid state or institutional browsing restrictions – Some governments, schools, and other organizations use firewalls to give their users access to a limited version of the Internet. A forward proxy can get around these restrictions, as it lets the user connect to the proxy rather than directly to the sites they visit.
- To block access to certain content – Conversely, proxies can also be set up to block a group of users from accessing specific sites. For example, a school network might be configured to connect to the web through a proxy that enables content filtering rules, refusing to forward responses from Facebook and other social media sites.
- To protect their identity online – Regular Internet users sometimes desire increased anonymity online. Still, in other cases, Internet users live where the government can impose severe consequences for political dissidents. Criticizing the government in a web forum or on social media can lead to fines or imprisonment for these users. If one of these dissidents uses a forward proxy to connect to a website where they post politically sensitive comments, the IP address used to post the comments will be harder to trace back to the dissident. Only the IP address of the proxy server will be visible.
How is a reverse proxy different?
A reverse proxy is a server that intercepts client requests in front of one or more web servers. This differs from a forward proxy, where the proxy sits before the clients. With a reverse proxy, when clients send requests to a website’s origin server, those requests are intercepted at the network edge by the reverse proxy server. The reverse proxy server will then send requests to and receive responses from the origin server.
The difference between a forward and reverse proxy is subtle but essential. A simplified way to sum it up would be to say that a forward proxy sits in front of a client and ensures that no origin server ever communicates directly with that specific client. On the other hand, a reverse proxy sits in front of an origin server and ensures that no client ever communicates directly with that origin server.
Once again, let’s illustrate by naming the computers involved:
- D: Any number of users’ home computers
- E: This is a reverse proxy server
- F: One or more origin servers
Typically, all requests from D would go directly to F. F would send responses directly to D. With a reverse proxy, all requests from D will go directly to E, and E will send its requests to and receive responses from F. E will then pass along the appropriate responses to D.
Below, we outline some of the benefits of a reverse proxy:
- Load balancing – A popular website that gets millions of users every day may not be able to handle all of its incoming site traffic with a single origin server. Instead, the site can be distributed among a pool of different servers, all handling requests for the same site. In this case, a reverse proxy can provide a load-balancing solution that will distribute the incoming traffic evenly among the different servers to prevent any single server from becoming overloaded. If a server fails, other servers can handle the traffic.
- Protection from attacks – With a reverse proxy in place, a website or service never needs to reveal the IP address of its origin server(s). This makes it much harder for attackers to leverage a targeted attack against them, such as a DDoS attack. Instead, the attackers can only target the reverse proxy, such as Cloudflare’s CDN, which will have tighter security and more resources to fend off a cyber attack.
- Global server load balancing (GSLB) – In this form of load balancing, a website can be distributed on several servers around the globe. The reverse proxy will send clients to the server that’s geographically closest to them. This decreases the distances that requests and responses need to travel, minimizing load times.
- Caching – A reverse proxy can also cache content, resulting in faster performance. For example, suppose a user in Paris visits a reverse-proxied website with web servers in Los Angeles. In that case, the user might connect to a local reverse proxy server in Paris, which will then have to communicate with an origin server in L.A. The proxy server can then cache (or temporarily save) the response data. Subsequent Parisian users who browse the site will get the locally cached version from the Parisian reverse proxy server, resulting in much faster performance.
- SSL encryption – Encrypting and decrypting SSL (or TLS) communications for each client can be computationally expensive for an origin server. A reverse proxy can be configured to decrypt all incoming requests and encrypt all outgoing responses, freeing up valuable resources on the origin server.
How to implement a reverse proxy
Some companies build their reverse proxies, which require intensive software and hardware engineering resources and a significant investment in physical hardware. One of the easiest and most cost-effective ways to reap all the benefits of a reverse proxy is by signing up for a CDN service.