Reverse proxy
A proxy host maps one or more domains onto one or more upstreams. It is what CPM is mostly for, and most other features attach to it.
Every host, HTTP or L4, can carry notes: free text for whatever the next person needs to know, up to 2000 characters. They show as an icon beside the host’s name in the list, with the text on hover, and the search box finds them. Anyone who can see the host can read them.
Hosts can also carry tags, such as prod, team:web or customer/acme, to find them again
in a long list. Type one in the editor and press Enter, or pick one other hosts already carry from
the suggestions; a pasted comma-separated list becomes several. A tag is stored in lowercase and
must start with a letter or digit, followed by letters, digits and . _ : / -, up to 40
characters, with at most 16 per host. Tags show under
the host’s name, the search box finds them, and the tag filter beside the tabs narrows the list to
the hosts carrying one. They label hosts and nothing more: Caddy’s configuration never sees them,
so tagging a host does not reload anything.
The list and its traffic
Section titled “The list and its traffic”With analytics on, the list shows each host’s last 24 hours beside its configuration, busiest first:
- Requests, with a bar against the busiest host the list’s filters match, and how many were blocked.
- 5xx: how many requests the host answered with a server error, and what share they were.
- Certificate: the days left on the certificate the host serves, its own imported one or the one Caddy manages for it (read from the agents, so it can take a moment to appear).
- Status: Healthy, Disabled, Maintenance, or the worst problem the host has. A problem is a burst of 5xx answers, 5xx making up 5% or more of at least 20 requests, unusual blocking (a spike in stopped requests, or 50 or more stopped on one path), or a certificate that has expired or is close to it.
- Protections: WAF, sign-in (with its kind), access list, mTLS, rate limit, geo blocking, CrowdSec and bot challenge, whichever the host has on.
Without analytics the list keeps its plain columns. Click a row, or the host’s name, to open its page; Edit in the row menu opens its edit page.
| Row status | 5xx | Certificate | ||||
|---|---|---|---|---|---|---|
app.example.com http://app-1:8080 +1prodteam:web WAFRate limit | 18,412 96 blocked | 1,2046.5% | 61 days | 5xx burst | ||
grafana.example.com http://grafana:3000monitoringprod Authentik | 5,730 | 30.1% | 8 days | Maintenance | ||
vpn.example.com http://headscale:8080mTLSGeo | 812 4 blocked | 0 | 74 days | Healthy | ||
staging.example.com http://staging:8080team:web | 0 | - | 212 days | Disabled |
A host’s page
Section titled “A host’s page”Each host has a page at /proxy-hosts/<id>:
- what needs attention about this host;
- its last 24 hours with analytics on: requests, 5xx count and share, distinct clients and bandwidth, a chart of served and 5xx responses every half hour with the 5xx share as a line, its busiest paths with their 5xx counts, and its status codes;
- its upstreams with their live health and health-check settings;
- a line for each part of the editor (General, Upstreams, Access, Protection, Routing, Advanced) that opens the editor at that part. The certificate is under General, beside the domains it covers, and client certificates (mTLS) under Access;
- for administrators, its recent changes from the audit log.
Tabs under the host’s name lead to its Edit page, /proxy-hosts/<id>/edit/general, and its
History.
An operator sees the page for a host their groups grant, without the recent changes; the tabs and
the edit links need a manage grant.
App
Needs attention
- app.example.com is answering with 5xx errors342 errors, 27% of its requests, from 9:30 AM to 11:58 AM.Critical
Responses every 30 minutes
Upstreams
- http://app-1:8080
- http://app-2:8080
Configuration
- General2 domains · 2 tags · Certificate managed by Caddy
- Upstreams2 upstreams · HTTPS forced · HSTS · WebSockets · Load balanced (round_robin) · Passive health checks
- AccessOpen to everyone
- ProtectionWAF · CrowdSec · Rate limited (0 zones)
- RoutingEverything to the upstreams
- AdvancedServed by every agent
Top paths
| Path | Requests | 5xx |
|---|---|---|
| /api/session | 6,120 | 301 |
| / | 3,480 | 12 |
| /assets/app.js | 2,960 | 0 |
| /api/search | 1,212 | 29 |
| /login | 640 | 0 |
Status codes
| Status | Requests |
|---|---|
| 200 | 13,904 |
| 304 | 1,870 |
| 502 | 312 |
| 404 | 188 |
| 503 | 30 |
Recent changes
| When | Change |
|---|---|
Updated proxy host Appavery | |
Added upstream http://app-2:8080 to Appavery | |
Created proxy host Appavery |
Reviewing a change before saving
Section titled “Reviewing a change before saving”The editor is grouped into the same parts as the host’s page. The bar at its top holds a tab for
each part, and at its end a count of the fields you have changed beside Review; on a phone the
count rides on the button. The arrow keys move along the bar, from the last tab on to the button.
In the new-host dialog a tab jumps to its part of one long form. A host’s edit page shows one part
at a time, each at its own address, such as /proxy-hosts/<id>/edit/protection; switching parts
keeps what you typed in the others, and Review covers them all. Links to the old
/proxy-hosts?edit=<id> still land on the editor.
Review, or Ctrl+S (Cmd+S on a Mac) anywhere in the open editor, asks the server what the save would do without saving anything. The answer runs every check the save runs, so a refusal shows here first, and lists:
- each changed field under its part of the editor, with what it was and what it becomes. A nested setting such as load balancing or the WAF lists only the values inside it that changed. Anything that looks like a secret - a sticky-session cookie secret, a token or password inside a custom Caddyfile or JSON snippet - is hidden on both sides;
- Undo beside each change, which leaves that field as stored for this save while the editor keeps your edit. Undone changes are listed below with Restore;
- what saving does: the agents that are sent a new config (every agent, or the ones the host is pinned to, offline ones marked), whether the host is pinned and whether that changes, and the new names Caddy will request a certificate for. A name an imported certificate or another host’s automatic wildcard already covers is not requested again;
- warnings: a domain another host already answers for, a protection this save takes away (WAF, sign-in, access list, mTLS, rate limiting, geo blocking, CrowdSec, bot challenge), a WAF moving to detection only, a sign-in changing kind, a rate-limit mode that changes which global zones apply, an access list with its own deny response, fail-closed behaviour or geo rules, an imported certificate that does not cover a domain, and a host being disabled or put into maintenance.
Save in the review saves what it shows; Ctrl+S there saves too. The save button in the editor’s footer still saves straight away. Closing the editor, leaving its page or closing the browser tab with unsaved changes asks first. Notes and tags reach no Caddy config, so a change to only those reloads nothing.
The same preview is in the API.
Duplicating a host
Section titled “Duplicating a host”Duplicate in a host’s row menu opens a new host’s editor filled in from that one, named with “(copy)” on the end. The domains are left empty, since two hosts cannot answer for the same name, and so is a sticky-session cookie secret: a secret is not copied into a new host. Whatever the host shares with others by reference - its certificate, access list, mTLS roles - stays selected. Like creating a host, it is for administrators.
Changing many hosts at once
Section titled “Changing many hosts at once”Tick hosts in the list and a bar replaces the filters: enable, disable or delete them, turn maintenance mode on or off, give them all one certificate (automatic included) or one access list (none included), or add a tag to each. Every action confirms with the names of the hosts it will touch.
A batch is all or nothing. If one host could not take the change - a wildcard domain asked to use
automatic certificates with no DNS provider, say - nothing is written and the dialog says why.
Each host gets its own row in the audit log, and Caddy is reloaded once for the
lot, or not at all for a tag. A host that would end up with more than 16 tags refuses the batch.
Selection covers the page you are looking at and clears when you page, filter, search or sort; it
is not offered on a phone. An operator can tick only the hosts their groups let them
manage. The API has the same actions as the bulkProxyHosts
mutation.
HTTPS and connection options
Section titled “HTTPS and connection options”Each host has switches at the top of its editor:
- Force HTTPS answers plain HTTP with a 308 redirect to the same URL over HTTPS.
- HSTS tells browsers to use only HTTPS for the host for two years, optionally including its subdomains. It needs Force HTTPS, because a browser pinned to HTTPS never tries HTTP again.
- WebSocket support lets upgrade requests through. The WAF checks the handshake like any other request, but not the messages after it. With it off, an upgrade is refused with a 403.
- Preserve Host header sends the domain the client asked for rather than the upstream’s own address.
- Discourage search engines adds
X-Robots-Tag: noindex, nofollowto every response, replacing any the upstream sent, and answers/robots.txtwith a file that disallows everything. Both come before access lists and sign-in, so a crawler sees them on a protected host too. Crawlers that follow the rules stay away; it keeps nobody out.
HTTP/2 and HTTP/3 are offered on every host. Settings → Network → HTTP versions turns either off, for all hosts at once: Caddy decides this per listening port, and every host shares one. HTTP/1.1 always stays on. Hosts served on a tailnet get HTTP/2 from the same switch, but HTTP/3 only when Serve HTTP/3 on tailnet listeners is on as well.
Responses are compressed with zstd or gzip, whichever the browser prefers, and turned off for every host in Settings → Network → Compression. Only text formats are compressed - HTML, CSS, JavaScript, JSON, XML, SVG and fonts - and only above 512 bytes; images, video, archives and anything the upstream already compressed pass through unchanged. A host’s Compression option can follow that setting (Default) or force it On or Off for that host alone, say for an upstream that compresses better itself. Server-sent events and WebSockets keep streaming.
Upstreams and load balancing
Section titled “Upstreams and load balancing”A host can have any number of upstreams. There are twelve selection policies, including round-robin, least-connections, weighted, and hashing by IP, query, header or cookie.
There are two kinds of health check:
- Active - CPM asks the upstream on an interval and takes failures out of rotation.
- Passive - failures on real requests count against an upstream, with a configurable number of failures and a duration to keep it out.
Retries let a failed request try another upstream rather than surfacing the error.
Live upstream health
Section titled “Live upstream health”A host’s editor shows how Caddy sees each of its upstreams right now, asked from every agent that serves the host when the editor opens and again on Recheck:
- Healthy - no recent failures.
- Failing - the number of recent failures, and whether that took the upstream out of rotation (it has reached the passive check’s maximum).
- Not checked - the host has no health checks, so Caddy is not counting failures.
- Not reported - Caddy does not list the address, for instance on an agent that has not loaded the host yet.
An agent that is offline or does not answer in five seconds is listed as unknown, never as a
failure, and a failing upstream on one agent is failing for the host. Caddy reports the failures
its passive checks count; it does not expose an active probe’s verdict, so a host with only
active checks shows its upstreams as healthy until real requests fail. Caddy keeps one pool
per address, so two hosts with the same upstream see the same counts. Anyone who can see the host
can see this; nothing is stored. The API has it as the proxyHostUpstreamHealth query.
Timeouts
Section titled “Timeouts”Caddy’s defaults suit most upstreams: three seconds to connect and no limit on anything after
that. Upstream timeouts change them per host, as durations such as 30s, 1m30s, 2h or
1d, and an empty field keeps the default:
- Connect - opening a connection, name lookup included.
- Response headers - from sending the request to the upstream answering.
- Read and Write - the longest wait for a single read from, or write to, the upstream.
- Idle connection - how long an unused connection is kept for reuse (two minutes by default).
- Stream lifetime - closes WebSockets and other upgraded connections after this long.
- Stream close delay - how long upgraded connections survive a configuration reload, rather than being closed at once.
Location rules use their host’s timeouts. A host that reaches its upstream through a Tailscale node keeps only the two stream settings, since that transport takes no others. The server-side read, write and idle timeouts belong to the listener rather than a host.
Location rules
Section titled “Location rules”Location rules route by path inside one host: send /api/* to one backend and /ws/* to another,
each with its own upstreams, load balancing and health checks. A rule can also use an
access list of its own, or none, instead of the host’s.
Redirects and rewrites
Section titled “Redirects and rewrites”Each host can have redirect rules with a status of 301, 302, 307 or 308. 307 and 308 preserve the
request method, which matters for anything but a GET. Keep path carries the rest of the request
along: Full path appends the whole path and query to the target, and After prefix drops
the part of the pattern before its * first, so /blog/* sends /blog/2024/post to
https://blog.example.com/2024/post. A path prefix can be prepended before the request
reaches the upstream.
Cache assets
Section titled “Cache assets”Cache assets covers stylesheets, scripts, images and fonts, matched by file extension. Pages and API responses are never cached. The max age runs from a minute to a year, a day by default.
- Browser sets
Cache-Control: max-age=<n>on successful asset responses whose upstream sent noCache-Controlof its own, so an application that already manages caching keeps its policy, and a 404 or 500 during a deploy is not kept for a day. - Caddy cache also keeps a shared copy in Caddy, so repeat requests skip the upstream. It needs
the opt-in HTTP Cache module (see Caddy build); until that is compiled
in, the host falls back to browser caching. The cache lives in memory unless another
storage is chosen, such as Redis to share it between
Caddys. A request carrying a cookie or an
Authorizationheader always goes to the upstream, so an asset an application serves per user never reaches the next visitor.
Either way, a response that sets a cookie gets private added to its Cache-Control, alongside
anything stricter the upstream sent, and nothing marked private or no-store is stored. The
cache sits after any forward auth or access check, just before the upstream, so an asset is never
served to a caller who could not fetch it.
Maintenance mode
Section titled “Maintenance mode”Maintenance mode answers every request to a host with a 503 Service Unavailable while its
upstream is being worked on. It is not the same as disabling the host: a disabled host stops
existing as far as Caddy is concerned and falls through to the default response, while a host in
maintenance keeps its certificate and tells visitors, and crawlers, that it will be back.
- Bypass addresses - IP addresses or CIDR ranges, one per line, that still reach the upstream, so you can check the site before reopening it. The client address is the one Caddy resolves through Settings → Network → Trusted proxies. Access lists, sign-in and the WAF still apply to a bypassing request.
- Retry-After - seconds, sent as the
Retry-Afterheader when set. - Page - the HTML visitors see. Left empty, the host’s own custom error page for a 503 is used, then the global one from Settings → Responses → Error pages, then a short built-in page.
The 503 comes before everything else in the host’s configuration but the WebSocket refusal - geo
blocking, the WAF, forward auth and location rules included - and is sent with
Cache-Control: no-store, so no cache keeps it past the maintenance window. Its settings are kept
while it is off. The host list shows a Maintenance status, and the row’s menu turns it on or off
in one click; either way the change is recorded in the audit log.
It never applies to the dashboard host, which would lock out the administrator who has to turn it off.
Rate limiting
Section titled “Rate limiting”Rate limiting answers a client that sends too many requests with 429 Too Many Requests and a
Retry-After header saying when to try again. It needs the opt-in Rate Limit module (see
Caddy build); until that is compiled in, the host is served without
limits and Caddy’s log says so.
A host has one or more zones, and each counts on its own:
- Paths - Caddy path patterns such as
/loginor/api/*. Empty covers every request. - Methods - only these methods count, such as
POSTon a sign-in form. None selected counts every method. - Requests and Per - how many requests one client may make within a sliding window, such
as 100 per
1m. - Count per - who “one client” is:
- Client IP, or client IP and path together, so each path gets its own allowance.
- Request header - each value of a header you name, such as
X-Api-Key, gets its own allowance. A request without the header is counted by its client IP, so leaving it off never escapes the limit. Clients choose their own header values, so pair it with a per-IP zone where that matters. - Signed-in user - the user forward auth signed in: CPM’s own,
Authentik (
X-Authentik-UidorX-Authentik-Username) or another forward-auth server sendingRemote-User. It is counted after sign-in, from the header the auth server set - one a client sends itself is stripped first - so one person on many addresses shares one allowance. Requests with no signed-in user, on paths forward auth leaves open or on a host without it, are counted by client IP.
- IPv6 prefix - counts a whole IPv6 network, such as a
/64, as one client, since one household or server usually holds far more addresses than it needs. Only with the client IP.
A header name is a plain token: braces, and so any placeholder of your own, are refused. Header and user values are never logged and never become metric labels.
The client IP is the one Caddy resolves through Settings → Network → Trusted proxies, so a
load balancer in front does not make every visitor look like one client. The limit is checked
before geo blocking and the WAF, so a flood never costs a WAF inspection. The 429 keeps its
Retry-After and is rendered by the host’s custom error page for it, or the global one from
Settings → Responses → Error pages. Counters are kept per Caddy and survive a configuration
reload; each agent counts on its own.
Global zones
Section titled “Global zones”Settings → Rate limiting holds zones every host can take. Each host chooses under Global zones:
- Inherit (the default for a new host) - only the global zones, none of its own.
- Merge - the global zones and its own.
- Override - only its own. Switched off, the host has no rate limiting at all.
A global zone counts per host: 100 requests a minute means 100 on each host, not 100 across all of them. Hosts saved before global zones existed keep their own zones and merge, which changes nothing until global zones are added. The dashboard host never takes global zones, so a tight one cannot keep out the administrator who has to loosen it.
The same page holds Never limited: addresses and CIDR ranges no zone counts, on any host, the host’s own zones included. A host and the global settings hold up to 20 zones each.
DNS controls
Section titled “DNS controls”Upstream DNS pinning resolves upstream hostnames when the configuration is applied and writes the addresses into Caddy’s config, rather than leaving Caddy to resolve them per request. You can choose IPv4, IPv6 or both. Custom resolvers can be set per host; their connect timeout bounds the lookup and the connection together, and a Connect timeout under Upstream timeouts wins over it.
Pinning is skipped for HTTPS upstreams when one handler has several different HTTPS hostnames, because a single pinned address cannot carry more than one SNI name.
Dynamic DNS
Section titled “Dynamic DNS”For a host on a connection whose public IP changes, Dynamic DNS under the domains keeps their A records, and AAAA records if IPv6 is on, pointed at the Caddy serving the host, through a DNS provider with saved credentials. The provider defaults to the default one, and the zone, left empty, is looked up from DNS when you save; a domain outside that zone is refused, and IP addresses among the domains are skipped. The records follow the bundled agent, or the agent the host is pinned to, never two at once. Interval, IP versions and TTL come from Settings → DNS → Dynamic DNS, and switching it on builds the Dynamic DNS module into Caddy.
Headers
Section titled “Headers”The host header is forwarded by default, which is what most applications behind a proxy expect; the Preserve Host header switch turns that off. Other request and response headers are set through the host’s advanced configuration fields, which take raw Caddy JSON and are admin-only.
Custom pre-handlers must be a JSON object or an array of objects, and the reverse proxy override a JSON object; anything else is refused on save with a 400, rather than silently dropped from the config. A stored value left unchanged still saves, so an older host is never stuck.