What is a reverse proxy? A self-hoster’s guide
A reverse proxy sits between the internet and your apps: one public address, HTTPS, routing by hostname. What it does, the headers it adds, and common traps.
A reverse proxy is a server that receives requests on behalf of other servers. Your browser connects to it, it decides which app behind it should answer, forwards the request, and passes the response back. To the browser it looks like one website; behind it there may be ten containers on ten different ports.
If you self-host more than one app on a server, you are almost certainly running one already — it is what lets n8n.example.com and vault.example.com share the same IP address and the same port 443.
Forward proxy vs reverse proxy
The two are easy to mix up. A forward proxy works for clients: a company routes its employees’ outgoing traffic through it, and websites see the proxy instead of the employee. A reverse proxy works for servers: visitors from anywhere reach it, and the apps behind it see the proxy instead of the visitor. Same mechanics, opposite side of the connection.
What a reverse proxy does for you
- One public entry point. Only ports 80 and 443 need to be open; the apps themselves listen on private addresses the internet never sees.
- Routing by hostname. The proxy reads the Host header (or the TLS server name) and picks the app: n8n.example.com goes to one container, wiki.example.com to another.
- TLS termination. The proxy holds the certificates and does the HTTPS work, so each app can speak plain HTTP on the private network and never touch a private key.
- Redirects and headers. Sending HTTP to HTTPS, adding security headers, compressing responses.
- A place to put shared rules: rate limits, access lists, request size limits, and — with the right proxy — a web application firewall.
The headers that matter
Because the proxy opens its own connection to the app, the app sees the proxy’s address as the client. To keep the real information, the proxy adds headers:
X-Forwarded-For: 203.0.113.42
X-Forwarded-Proto: https
X-Forwarded-Host: n8n.example.comApps that care — for logs, rate limits, or to build correct links — read these. But an app must only trust them from a proxy it knows; otherwise any visitor can send a fake X-Forwarded-For and pretend to be someone else. That is why many apps have a setting for “trusted proxies” or “proxy hops”. The n8n entry in the Keenrig catalog, for example, sets N8N_PROXY_HOPS=1, telling n8n there is exactly one proxy in front of it.
Common traps
- Redirect loops: the app does not know the original request was HTTPS, so it redirects to HTTPS, which arrives at the app as HTTP again. Fix: forward X-Forwarded-Proto and make the app trust it.
- Wrong links in emails and webhooks: the app builds URLs from its internal address. Most apps have a “public URL” setting; Keenrig sets n8n’s WEBHOOK_URL to the app’s first domain for this reason.
- WebSockets dropping: some proxies need explicit settings to upgrade connections or to keep long idle connections open.
- Uploads failing at a certain size: the proxy has its own body size limit, separate from the app’s.
- Every visitor appears to come from one address: the app is not reading the forwarded headers, so per-client rate limits and audit logs are useless.
Reverse proxy, load balancer, CDN, tunnel
These overlap. A load balancer is a reverse proxy that spreads requests across several copies of the same app. A CDN is a large network of reverse proxies close to your visitors that also caches content. A tunnel (such as Cloudflare Tunnel) is a reverse proxy at the provider’s edge that reaches your server over an outbound connection, which is how a machine without a public IP can still serve a website. In each case, the party running the proxy terminates TLS and can read the traffic — worth remembering when the proxy is someone else’s.
Popular reverse proxies
For self-hosting, the usual choices are Caddy (automatic HTTPS, short config), Traefik (routes built from Docker labels) and Nginx (explicit config, huge ecosystem). HAProxy is common for pure load balancing. Nginx Proxy Manager puts a web interface on top of nginx for people who prefer clicking to editing files. We compare the first three in “Caddy vs Traefik vs Nginx for self-hosting”.
Seeing it from the outside
You can watch a reverse proxy at work with curl. Ask for the headers of an app, then for the same app over plain HTTP:
curl -sI https://n8n.example.com | head -5
curl -sI http://n8n.example.com | head -5The first answer comes from the app, through the proxy, over a certificate the proxy holds. The second is usually a redirect (301 or 308) to the HTTPS address, sent by the proxy without the app ever seeing the request. A Server header in the response often names the proxy rather than the app — another sign of who you are actually talking to.
How it works on Keenrig
Keenrig installs Caddy as the gateway and manages it for you. When you install an app from the catalog with a domain, Keenrig adds the route, Caddy obtains the certificate, and the app’s container stays on Docker’s internal network without any port published on the host. You never write a server block or a label.
If you want to see exactly what the gateway forwards, install the whoami app from the catalog. It is a diagnostic app that prints the headers and address of every request it receives — X-Forwarded-For, X-Forwarded-Proto and the rest — so when routing misbehaves you can see why rather than guess.
Limits
- A reverse proxy is not a security product by itself. It reduces what is exposed, but a vulnerable app behind it is still vulnerable.
- On Keenrig the gateway is Caddy only, with no web application firewall today, and you cannot add custom proxy rules from the admin panel.
- A proxy cannot give you a public address. If your server sits behind CGNAT, you need a tunnel or a VPS — see our guide on self-hosting without a public IP.