Skip to content
Distr
Book DemoStart free trialLogin
← Back to Glossary

Reverse Proxy: What It Is and How to Ship One With Self-Hosted Software

A reverse proxy accepts requests on behalf of one or more backend services and forwards them. Learn what reverse proxies do, which ones are common and what vendors of self-hosted software have to get right behind one.

What Is a Reverse Proxy?

A reverse proxy is a server that accepts requests on behalf of one or more backend services and forwards them. Clients only ever talk to the proxy and do not see which backend answers or where it runs.

“Reverse” sets it apart from a forward proxy, which acts for the clients. A company proxy that all outgoing web traffic passes through is a forward proxy. A reverse proxy acts for the servers and sits in front of them.

What a Reverse Proxy Does

The most common job is TLS termination. The proxy holds the certificates and decrypts HTTPS, and the backends serve plain HTTP on an internal network. Caddy and Traefik can obtain and renew the certificates through ACME by themselves.

The proxy also routes requests to different backends by hostname or path, so one public address can serve many services. When a backend runs several instances, the proxy spreads the requests across them and stops sending traffic to an instance that fails its health check. With weighted upstreams it can send a share of the traffic to a new version, which is how blue-green and canary deployments switch versions without downtime.

On the way through, a proxy can add headers, compress responses, limit request rates or require authentication before a request reaches the backend.

Common Reverse Proxies

ProxyKnown for
CaddyAutomatic HTTPS with almost no configuration
TraefikConfiguration from Docker labels and Kubernetes resources
HAProxyHigh-throughput load balancing on layer 4 and layer 7
EnvoyThe data plane of many service meshes and Kubernetes gateways

In Kubernetes, the cluster provides the reverse proxy through Ingress or the Gateway API, and applications only declare the routes they need.

Reverse Proxy vs. Load Balancer vs. Reverse Tunnel

A load balancer that works on layer 7 reads HTTP requests, which makes it a reverse proxy whose main job is spreading load. A layer 4 load balancer only forwards TCP or UDP connections, so it cannot route by path, pick a certificate per hostname or set headers.

A reverse tunnel solves a different problem. A reverse proxy has to be reachable, since it accepts inbound connections and forwards them to backends it can reach. With a reverse tunnel, an agent next to the service dials out to a relay, and the service becomes reachable without any inbound connection into its network. The two often work together: Cloudflare’s edge, for example, acts as a reverse proxy for the requests it sends through a Cloudflare Tunnel.

Reverse Proxies in Self-Hosted Software

Vendors of self-hosted software have to decide whether to ship a reverse proxy or leave it to the customer.

For Docker Compose, shipping one is often the friendlier choice. A Caddy service in the Compose file gives the customer HTTPS on their own domain without extra setup. Many customers already run a proxy or a load balancer, though, so make the bundled one optional and document how to run the application behind theirs.

For Kubernetes, leave the proxy to the cluster. Most clusters already offer Ingress or the Gateway API, and a proxy installed by your Helm chart would need cluster-wide permissions and a load balancer of its own, which a shared cluster rarely allows. Ship the routing in the chart as an option, and let the customer set the hostname, the TLS certificate and whatever else their setup needs.

What to Get Right Behind a Proxy

Support cases about reverse proxies tend to come back to the same few settings.

Behind a proxy, every request comes from the proxy’s address. The proxy passes the original client address in X-Forwarded-For and the original scheme and host in X-Forwarded-Proto and X-Forwarded-Host. The application has to read these headers, but only when they come from a proxy it trusts, since any client can send them too.

The backend receives plain HTTP and cannot tell from the request whether users reach it over HTTPS. Let customers configure the public URL, and build redirects, links in emails and OAuth callbacks from it.

WebSockets need the Upgrade and Connection headers passed through, and some proxies only do that when configured to. Proxies also close connections that stay idle for too long, which cuts off long polling and log streams.

Many proxies limit the size of a request body and answer larger requests with 413 Request Entity Too Large. File uploads and container image pushes need that limit raised. Exports and other long-running requests need a proxy timeout longer than the request takes.

Customers who run their own proxy hit these settings one by one, so write down what your application needs for the common proxies.

Reverse Proxies with Distr

Distr itself runs behind a TLS-terminating reverse proxy: Caddy in the Docker Compose setup and an Ingress controller in Kubernetes, as described in the system requirements.

Vendors who distribute their software with Distr can ship a proxy as a deployment of its own. The blue-green deployments guide uses Caddy with weighted upstreams to switch traffic between two versions of an application without downtime. For Docker Swarm, Load Balancing and Routing in Docker Swarm compares the built-in routing mesh with Traefik and other proxies.

Frequently Asked Questions

What is a reverse proxy?

A reverse proxy is a server that sits in front of one or more backend services, accepts requests from clients and forwards them to the right backend. Clients only ever talk to the proxy. Caddy, Traefik, HAProxy and Envoy are common examples.

What is the difference between a forward proxy and a reverse proxy?

A forward proxy acts for the clients, for example a company proxy that all outgoing web traffic passes through. A reverse proxy acts for the servers: it receives requests from the internet and forwards them to backends that clients never reach directly.

Is a load balancer a reverse proxy?

A layer 7 load balancer that reads HTTP requests is a reverse proxy with a focus on spreading load. A layer 4 load balancer only forwards TCP or UDP connections and does not see the requests, so it cannot route by path or set headers.

Should self-hosted software ship its own reverse proxy?

For Docker Compose, shipping an optional proxy such as Caddy gives customers HTTPS out of the box, as long as they can turn it off and use their own. For Kubernetes, leave the proxy to the cluster, which usually offers Ingress or the Gateway API, and make the routing in your chart configurable.

Why does my application see the wrong client IP behind a reverse proxy?

Behind a proxy, every request comes from the proxy's address. The proxy passes the original client address in the X-Forwarded-For header, and the application has to read it from there, trusting only the entries added by proxies it knows.

Turn self-hosted into a repeatable sales motion

From your first on-prem POC to dozens of enterprise customers, the Distr platform gives you the tooling to deploy, update and manage self-hosted customers, backed by a team that supports you hands-on with the deployment knowledge and implementation help.

Proof from teams shipping self-hosted software

GovCloud deployments without extra overhead

"Distr gives us a clean way to deploy and update our software in GovCloud without breaking security or adding operational overhead."

Corbin Klett

Corbin Klett

Co-Founder, Artifact

Updates that took days now take minutes

"Distr eliminated nearly all deployment headaches. Updates that used to take days now take minutes."

Ansh Gupta

Ansh Gupta

Co-Founder & CTO, Candor

Read case study

From guided setup to scalable delivery

"We went from hands-on Docker setup calls to an install flow that can be running in minutes."

Daniel Kasen

Daniel Kasen

Chief Engineer for Customer Success, Ozgar AI

Read case study

Deploy into regulated industries without cluster access

"Distr is a super useful tool, especially when we need to deploy into regulated industries where we cannot have direct access to the cluster."

Wyatt Stagg

Wyatt Stagg

Software Developer, Trelent

One place for every self-hosted customer

"Having a dedicated space for all our self-hosted customers that can manage authenticated registry access is great."

Derek Reynolds

Derek Reynolds

Product Engineer, Basedash

Read case study

Manual operations become one-click workflows

"Our main goal is to simplify the daily operations. No more manual installations, updates, or rollbacks — everything can now be handled with a single click with Distr."

Jefferson Rodrigues

Jefferson Rodrigues

Co-Founder & CTO, Lerian

Read case study

Closing the Kubernetes distribution gap

"Self-hosted products had a distribution problem, which we noticed. And it was even trickier with Kubernetes installations, getting a Helm chart into and on a customer's cluster. We found Distr looking to fill that gap with their product. We couldn't be happier with Distr as a provider, they are smart, quick and helpful: the golden trio. Working with them has been a pleasure and we love seeing the platform evolve."

Jack Fenton

Jack Fenton

Platform Engineer, Snicket Labs

Self-hosted without the engineering tax

"Weave has a fully self-hosted offering. It's a huge unlock for us, but we almost didn't build it. Distr made such a huge difference in getting us there."

Andrew Churchill

Andrew Churchill

Co-Founder & CTO, Weave

Read case study