Skip to content

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.

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.

The proxy host listBusiest first. Sort by requests, domain or status, switch to the enabled or disabled hosts, pick a tag, or hover the note on staging. Grafana is in maintenance mode. Tick a few rows to disable them together.Nothing you change here is saved
Proxy hosts
4
3 enabled, 1 disabled
Requests, 24h
24,954
0.4% blocked
Certificates
3
3 hosts on this page carry one
Agents
3one or more offline
2 connected
Row status
5xxCertificate
app.example.com
http://app-1:8080 +1
prodteam:web
WAFRate limit
18,412
100% of the busiest host
96 blocked
1,2046.5%
61 days
5xx burst
grafana.example.com
http://grafana:3000
monitoringprod
Authentik
5,730
31% of the busiest host
30.1%
8 days
Maintenance
vpn.example.com
http://headscale:8080
mTLSGeo
812
4% of the busiest host
4 blocked
074 days
Healthy
staging.example.com
http://staging:8080
team:web
-
0
0% of the busiest host
-
212 days
Disabled

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.

A host's pageSample data: a 5xx burst still going on, which the status, the attention list and the chart all show.Nothing you change here is saved
Proxy hosts

App

5xx burst
app.example.com, www.app.example.com
prodteam:web

Needs attention

  • app.example.com is answering with 5xx errors342 errors, 27% of its requests, from 9:30 AM to 11:58 AM.Critical
Requests, last 24 hours
18,240
96 stopped by a gate
5xx responses
362
2% of requests
Distinct clients
1,284
Bandwidth
661.0 MB

Responses every 30 minutes

Upstreams

  • http://app-1:8080
  • http://app-2:8080
No active health checksPassive health checks: out of rotation after 3 failures for 30s
Live upstream healthAsking Caddy…

Configuration

WAFRate limitCrowdSec
59 days
  • 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

PathRequests5xx
/api/session6,120301
/3,48012
/assets/app.js2,9600
/api/search1,21229
/login6400

Status codes

StatusRequests
20013,904
3041,870
502312
404188
50330

Recent changes

WhenChange
Updated proxy host Appavery
Added upstream http://app-2:8080 to Appavery
Created proxy host Appavery
Tags in the host editorType a tag and press Enter, or pick one other hosts already carry; start one with a dash to see it refused.Nothing you change here is saved
Labels for finding this host in the lists, at most 16. They do not change how it is served
prodteam:web

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.

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.

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.

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, nofollow to every response, replacing any the upstream sent, and answers /robots.txt with 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.
Host optionsTurn off Force HTTPS and HSTS follows.Nothing you change here is saved
Proxy host enabled
This host is active and routing traffic
Advanced options
Redirect plain HTTP requests to HTTPS
Tell browsers to only ever use HTTPS for this host. Requires Force HTTPS
Include subdomains in the Strict-Transport-Security header
Allow WebSocket upgrades. The WAF checks the handshake but not the messages after it
Send the original Host header to the upstream instead of the upstream's own address
Skip TLS certificate hostname verification for backend connections
Ask search engines not to index this host: every response gets X-Robots-Tag: noindex, nofollow, and /robots.txt disallows everything, even behind a sign-in. Well-behaved crawlers honour it; it doesn't keep anyone out
Caddy writes no access-log line for this host, so it does not appear in the log viewer or analytics. Useful for a dashboard or health-check host that would otherwise fill the log
CompressionCompress text responses with zstd or gzip. Default follows Settings → Network → Compression

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.

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.

UpstreamsAdd one, or switch a scheme.Nothing you change here is saved
UpstreamsFirst available tries them from the top; drag a row by its handle to change the order.

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.

Load balancing and health checksChange the policy to see what each one asks for.Nothing you change here is saved
Load balancerConfigure load balancing and health checks for multiple upstreams
Retry settings
How long to try upstreams
Wait between attempts
Maximum retry attempts
Periodically probe upstreams to check health
Path to probe for health
Override upstream port
How often to check
Timeout for health probe
Expected HTTP status
Expected response body
Consecutive successful probes before an upstream is used again.
Consecutive failed probes before an upstream is taken out.
GET when unset.
Sent with the probe. Distinct from the expected response body.
Mark upstreams unhealthy based on response failures
How long to remember failures
Failures before marking unhealthy
Comma-separated status codes
Latency above which an upstream is marked unhealthy
Concurrent requests to one upstream before it is considered unhealthy.

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.

Live upstream healthOne upstream has reached its failure limit on edge-fra; edge-ams is offline, so its view is unknown.Nothing you change here is saved
Live upstream healthAsking Caddy…

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.

Upstream timeoutsType something that is not a duration to see it refused.Nothing you change here is saved
Upstream timeoutsHow long to wait on the upstream before giving up. A field left empty keeps Caddy's default, and location rules use the same values
Opening a connection, name lookup included. Caddy's default is 3s
From sending the request to receiving the response headers. No limit by default
The longest wait for the next read from the upstream. No limit by default
The longest wait for a write to the upstream. No limit by default
How long an unused connection is kept open for reuse. Caddy's default is 2m
Closes WebSockets and other upgraded connections after this long. No limit by default
How long upgraded connections survive a config reload. Closed at once by default
Through a Tailscale node only the two stream settings apply
The host editor's raw-config fieldsNothing you change here is saved
Caddyfile directives for this host, adapted by Caddy and inserted before the reverse proxy. Rejected on save if Caddy cannot parse them.
Tab indents; press Escape then Tab to leave the fieldCaddyfile
JSON array of Caddy handlers, run before the reverse proxy.
Tab indents; press Escape then Tab to leave the fieldJSON
Deep-merged into the reverse_proxy handler itself (proxy mode only).
Tab indents; press Escape then Tab to leave the fieldJSON

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.

Location rulesExpand a rule to give it its own load balancer, or change the access list it uses.Nothing you change here is saved
Location rules
Upstreams
Load balancerHealth checks & balancing for this path's upstreams
Upstreams
Load balancerHealth checks & balancing for this path's upstreams

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.

Redirects and path rewritesNothing you change here is saved
Redirects
Path rewrites
Internally rewrite the request URI before proxying. The client URL is unchanged; the upstream sees the target URI.

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 no Cache-Control of 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 Authorization header 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 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-After header 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 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 /login or /api/*. Empty covers every request.
  • Methods - only these methods count, such as POST on 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-Uid or X-Authentik-Username) or another forward-auth server sending Remote-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.

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.

Rate limitingSwitch the key to a header or the signed-in user, or the global zones to inherit.Nothing you change here is saved
Rate limitingAnswer clients that send too many requests with 429 Too Many Requests, before geo blocking and the WAF see them.
The zones in Settings > Rate limiting apply, and so do the ones below. Each keeps its own count.
Zone 1
Caddy path patterns separated by spaces, such as /login or /api/*. Empty covers every request.
Only these methods count. None selected counts every method.
Zone 2
Caddy path patterns separated by spaces, such as /login or /api/*. Empty covers every request.
Only these methods count. None selected counts every method.
Counts per value of this header, such as an API key. A request without it is counted by its client IP. Clients choose their own header values, so pair it with a per-IP zone if that matters.
Each zone allows a number of requests per client in a sliding window. A request over the limit gets a 429 with Retry-After, rendered by this host's 429 error page when it has one. The client IP honours trusted proxies. An IPv6 prefix such as 64 counts a whole network as one client. Addresses on the never-limited list in Settings > Rate limiting are never counted.

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.

Upstream DNS pinningOpen it to override the global default.Nothing you change here is saved
Inherit uses the global setting. Enabled/Disabled overrides per host.
Both resolves AAAA and A records and orders IPv6 addresses first.
Hostname upstreams are resolved at config-apply time
When enabled, hostname upstreams are written to Caddy as IP dials. If this handler has more than one distinct HTTPS upstream hostname, those HTTPS upstreams are not pinned, to avoid an SNI mismatch.

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.

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.

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.