A reverse proxy is an in­ter­me­di­ary network component that sits in front of the servers of a public online service: it accepts requests from clients on behalf of those servers and returns the servers’ responses to the user. Because every request passes through this single point, a reverse proxy is able to filter, cache, dis­trib­ute and encrypt traffic before it reaches the systems behind it.

Key Takeaways

A reverse proxy stands in front of your web and ap­pli­ca­tion servers, takes in every client request and decides how that request is answered – which makes it a central point for security, per­for­mance and avail­abil­i­ty.

  • How it works: the proxy receives the request, checks it, answers it from its cache or forwards it to a backend server and passes the response back to the client.
  • Dif­fer­ence from a forward proxy: a forward proxy acts for clients toward the internet, a reverse proxy acts for servers toward the clients.
  • Load balancing: it spreads requests across several backend servers and routes around servers that have failed.
  • Caching and com­pres­sion: it answers repeat requests for static content itself and com­press­es responses, which takes load off the backend.
  • Security: rate limiting, a web ap­pli­ca­tion firewall, IP al­lowlist­ing and hidden backend addresses keep attacks away from your servers.
  • En­cryp­tion: the proxy can terminate TLS centrally, so cer­tifi­cates are managed in one place instead of on every server.

How does a reverse proxy work?

Es­sen­tial­ly, a proxy server functions as a com­mu­ni­ca­tion in­ter­me­di­ary in the network: it receives requests and passes them along to a target server on behalf of the client. A reverse proxy is po­si­tioned between clients (e.g., web browsers) and backend servers (e.g., web servers, database servers or ap­pli­ca­tions). It becomes active as soon as a client request arrives and decides whether the request is answered at all and which of your internal server com­po­nents should handle it. The process follows these four basic steps:

  1. Receiving the client request: The reverse proxy accepts HTTP, HTTPS or other requests like FTP or WebSocket.

  2. Analyzing the request: The proxy examines whether the request is valid, whether it presents any security risks and if there is a cached version available.

  3. For­ward­ing to the ap­pro­pri­ate server: If the request cannot be answered from the cache, the reverse proxy sends the request to one of your internal servers.

  4. Response to the client: The reverse proxy receives the response from your backend server, processes it further if necessary (e.g., re-en­crypt­ing it) and sends it back to the re­quest­ing client.

Because the client only ever addresses the reverse proxy, the backend servers never appear directly on the internet. How many of them there are, which addresses they use and which software they run stays invisible from the outside – and you can rebuild the setup behind the proxy without changing the URL that your users call.

Image: Schematic representation of a reverse proxy
Reverse proxy and web server are located in a shared internal network
Note

Reverse proxies are usually secured by a firewall and installed in a private network or an upstream de­mil­i­ta­rized zone (DMZ).

What is the dif­fer­ence compared to forward proxies?

While reverse proxies, as mentioned earlier, are placed between clients and backend servers, forward proxies are po­si­tioned between clients and the internet. A forward proxy channels all client requests and forwards them with its own sender address to the target servers on the internet. Server responses also reach the proxy first before being dis­trib­uted to the re­spec­tive client devices. These remain anonymous – unless it is a trans­par­ent proxy. While a forward proxy protects the clients in your internal network from external threats, a reverse proxy secures your servers in a public network and optimizes their ac­ces­si­bil­i­ty.

While reverse proxies offer clear ad­van­tages for your server struc­tures through features like load balancing and various security functions, the strengths of forward proxies lie in client pro­tec­tion.

Forward proxy Reverse proxy
Acts on behalf of the clients the servers
Position in the network between the clients and the internet between the internet and the backend servers
Hides the clients from the target server the backend servers from the clients
Typically operated by a company for its own network the operator of the online service
Main purpose con­trol­ling and anonymiz­ing outbound access security, avail­abil­i­ty and speed of the service

If you are not sure which of the two you need, the decisive question is whose side you are on: a forward proxy is set up by whoever owns the clients, a reverse proxy by whoever owns the servers.

Image: Schematic representation of a forward proxy
Unlike a reverse proxy, the forward proxy is located in a shared internal network with the clients.
Note

Forward proxies are often used to control internet access in corporate networks. Other areas of use include anonymiza­tion in VPN services and bypassing geo-blocks.

Areas of ap­pli­ca­tion for reverse proxies

Bundling client requests allows a reverse proxy to exercise a high degree of control over incoming traffic. Among other things, this makes it possible to provide multiple servers under the same URL, evenly dis­trib­ute requests across different servers and speed up data retrieval through caching. Below are the key areas of ap­pli­ca­tion for a reverse proxy server.

IONOS CLOUD Compute Engine
The ideal IaaS for your workload
  • Cost-effective vCPUs and powerful dedicated cores
  • Flex­i­bil­i­ty with no minimum contract
  • 24/7 expert support included

Load balancing

A reverse proxy placed in front allows a URL to be linked with various servers in your private network. This dis­trib­utes incoming requests across multiple servers. Such load balancing prevents overload of in­di­vid­ual systems and com­pen­sates during failures. If a server is un­reach­able due to hardware or software errors, the proxy’s load balancing module re­dis­trib­utes incoming requests to remaining servers. This ensures the avail­abil­i­ty of your server services even during failures.

Which server receives a given request is decided by the dis­tri­b­u­tion method you configure – in rotation (round robin), by the number of open con­nec­tions or weighted so that stronger machines take a larger share. To notice a failure at all, most reverse proxies query the backend servers at regular intervals with health checks and take a server out of the rotation as soon as it stops answering correctly.

Caching

To speed up your server services, reverse proxies can offer a feature that allows fre­quent­ly requested content to be cached. This caching enables the proxy server to answer repet­i­tive requests either partially or com­plete­ly on its own. Static content like images or CSS stylesheets is stored in the proxy’s cache. As a result, little to no data needs to be retrieved from your backend server, which no­tice­ably shortens the response time for web services. However, because rapidly changing content may not always ensure the proxy’s cache has the current version, there’s a risk of de­liv­er­ing outdated in­for­ma­tion to re­quest­ing clients.

How long a stored response may be reused is con­trolled by the cache headers your backend sends, above all Cache-Control and Expires. For content that changes fre­quent­ly, keep these intervals short or exclude those paths from caching entirely.

Pro­tec­tion and security measures

A reverse proxy acts as a kind of shield for your backend servers and can offer various security functions in this role:

  • DDoS pro­tec­tion: Reverse proxies can detect and block sus­pi­cious or unusually high traffic during DDoS attacks before it reaches your backend servers.
  • Rate limiting: You can cap how many requests a single IP address or session is allowed to make within a given period. This blunts automated attempts to guess login cre­den­tials and keeps ag­gres­sive crawlers from using up backend capacity.
  • Web Ap­pli­ca­tion Firewall (WAF): Many reverse proxies include a WAF that can filter malicious requests like SQL in­jec­tions or Cross-Site Scripting (XSS).
  • IP al­lowlist­ing and block­list­ing: The reverse proxy can block certain IP addresses or allow con­nec­tions only from specific networks if needed. The older terms whitelist­ing and black­list­ing describe the same mechanism.
  • Hiding of backend servers: The reverse proxy prevents the internal IP addresses of your backend servers from being publicly visible, making attacks more difficult.
  • Central logging: Because all traffic passes through one point, you get a single place in which requests, response codes and blocked attempts are recorded – which makes unusual patterns easier to spot than in the logs of several separate machines.

A reverse proxy does not replace the security of the systems behind it. In the US, the guidance that CISA publishes on denial-of-service attacks treats upstream filtering of this kind as one building block among several, alongside hardening the ap­pli­ca­tion itself and preparing a response plan before an incident occurs.

En­cryp­tion and TLS ter­mi­na­tion

To reduce the load on your backend servers, reverse proxy servers can also be used for en­cryp­tion. In this case, it decrypts the client’s SSL/TLS request (e.g., an HTTPS con­nec­tion), forwards the decrypted data to your backend servers and sends the cor­re­spond­ing response back to the client encrypted again. This arrange­ment is known as TLS ter­mi­na­tion or SSL of­fload­ing. The internal com­mu­ni­ca­tion can occur either encrypted or un­en­crypt­ed.

Ter­mi­nat­ing the en­cryp­tion centrally has a practical advantage: you install, renew and revoke cer­tifi­cates in one place instead of on every backend server. Be aware, though, that the con­nec­tion between the proxy and the backend is readable unless you encrypt that leg sep­a­rate­ly – which is why this segment belongs in a protected network, as described above.

Anonymiza­tion and geo-load balancing

A reverse proxy also changes what your backend servers get to see. Because the con­nec­tion ends at the proxy, the backend receives requests carrying the proxy’s IP address instead of the client’s. This helps protect your visitors’ privacy, as the actual IP addresses won’t be visible in the logs. In most setups, however, the client address is passed on in a header such as X-Forwarded-For, because ap­pli­ca­tions need it for rate limiting, ge­olo­ca­tion and handling abuse – so decide de­lib­er­ate­ly whether you want that header to be set.

Geo-load balancing works the other way around: here the proxy evaluates the ge­o­graph­ic location derived from the client’s IP address in order to route the request to the nearest server. Anonymiza­tion and geo-routing therefore pull in opposite di­rec­tions, and you need to decide which of the two matters more for your service.

Com­pres­sion

With the right software, a reverse proxy can compress the data it sends out before it reaches the client, which reduces transfer volume on slow con­nec­tions in par­tic­u­lar. A popular program for com­press­ing websites is gzip, often used in com­bi­na­tion with the web servers Apache or NGINX. Brotli is now widely used alongside it and generally produces smaller files for text content such as HTML, CSS and JavaScript.

Com­pres­sion costs computing time, so it is worth re­strict­ing it to file types that actually benefit. Images and videos are already com­pressed in their own formats and gain nothing from a second pass.

Which software can act as a reverse proxy?

Most common web servers can be operated as a reverse proxy, and which one you choose usually depends on what is already running in your in­fra­struc­ture:

  • NGINX is widely used as a reverse proxy and load balancer and is con­fig­ured through its own di­rec­tives.
  • Apache HTTP Server takes on the role through its proxy modules, which is the obvious route if Apache is already serving your ap­pli­ca­tion.
  • HAProxy spe­cial­izes in load balancing and con­nec­tion handling rather than de­liv­er­ing files itself.
  • Traefik and Envoy are fre­quent­ly chosen for con­tainer­ized en­vi­ron­ments, where backends appear and disappear and the con­fig­u­ra­tion has to follow au­to­mat­i­cal­ly.

What matters for the decision is less raw through­put than how well the con­fig­u­ra­tion fits your de­ploy­ment process – a proxy whose rules nobody dares to touch is a risk of its own.

Tip

In separate articles, we show you step by step how to set up an NGINX reverse proxy or an Apache reverse proxy.

Reviewer

Go to Main Menu