Merge pull request #524 from trails-cool/sec-caddy-admin

security: bind Caddy admin API to loopback (split metrics to :2020)
This commit is contained in:
Ullrich Schäfer 2026-06-11 08:00:38 +02:00 committed by GitHub
commit b4067301cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View file

@ -1,6 +1,17 @@
{
metrics
admin 0.0.0.0:2019
# Admin API on loopback only. It can reconfigure the proxy, so it must
# not be reachable by other containers on the Docker network (a journal
# / planner RCE could otherwise rewrite routes). Reloads run in-container
# (`docker compose exec caddy caddy reload`) over this loopback endpoint,
# matching infrastructure/brouter-host/Caddyfile.
admin localhost:2019
}
# Read-only Prometheus metrics on a dedicated network-reachable port,
# split off the admin endpoint above so scraping doesn't require exposing
# the admin API. Prometheus scrapes caddy:2020 (see prometheus.yml).
:2020 {
metrics /metrics
}
(security_headers) {

View file

@ -41,7 +41,9 @@ scrape_configs:
- job_name: "caddy"
static_configs:
- targets: ["caddy:2019"]
# Caddy's admin API is loopback-only; metrics are served on a
# dedicated port (see infrastructure/caddy/Caddyfile).
- targets: ["caddy:2020"]
# Self-monitoring. Prometheus did not scrape its own /metrics, so TSDB
# health (compaction failures, WAL corruption, head series, retention