v0.7.1 · updated · GitHub

Configuration

How the tool itself is configured. For how to connect to each log source, see Log Sources.

Config file — where it lives

Two locations, first hit wins:

PathScope
./caddy-analyzer.jsonLocal (project)
~/.config/caddy-analyzer/config.jsonGlobal (XDG)

~/.config follows XDG_CONFIG_HOME if set, else os.UserConfigDir(). Dirs are created 0750, files 0600.

Schema

{
  "source": "docker://caddy",
  "namespace": "production",
  "blocklist": {
    "no_defaults": false,
    "custom_sources": [{ "name": "My List", "url": "https://example.com/list.txt" }],
    "remove_sources": ["tor-exit-nodes"]
  },
  "tuning": {
    "geo_cache_ttl": "24h",
    "geo_cache_size": 50000,
    "iptables_timeout": "10s"
  }
}

Manage it

caddy-analyze config                    # show active file + source
caddy-analyze config /var/log/caddy/access.log          # set local
caddy-analyze config docker://caddy --global            # set global
caddy-analyze config k8s://caddy-xxx -n production     # with namespace
caddy-analyze config reset              # remove local
caddy-analyze config reset --global     # remove global
caddy-analyze blocklist init            # persist blocklist flags to config
caddy-analyze whitelist --init          # persist never-block to /etc/caddy-analyzer/whitelist.txt

blocklist init writes current --no-default-blocklists / --blocklist-config / --blocklist-remove into the same file so guard picks them up without CLI flags.

Tuning — precedence

Config file values are defaults; CLI flags override when explicitly set. The three tunables:

KeyConfig fieldCLI flagDefault
GeoIP cache TTLtuning.geo_cache_ttl--geo-cache-ttl 24h24h (0 = off, slow)
GeoIP cache sizetuning.geo_cache_size--geo-cache-size 5000050000
iptables timeouttuning.iptables_timeout--iptables-timeout 10s10s
# example: keep GeoIP results longer on a busy host
caddy-analyze --geo-cache-ttl 48h --geo-cache-size 100000 /var/log/caddy/access.log

Environment & XDG

VariableAffects
XDG_CONFIG_HOMEGlobal config dir (~/.config/caddy-analyzer)
HOMEFallback for config/cache
https_proxy / http_proxyBlocklist fetches and GeoIP auto-download

Caches & state (not config)

PathWhat
~/.cache/caddy-analyzer/blocklists/Blocklist CIDRs (7d TTL)
~/.config/caddy-analyzer/GeoLite2-*.mmdbGeoIP (auto-download from P3TERX mirror)
/var/lib/caddy-analyzer/blocked.jsonGuard blocked IPs (survives restart)
/var/log/caddy-analyzer-audit.jsonlAudit log (0600, JSON lines)
/etc/caddy-analyzer/whitelist.txtNever-block list (CIDRs, # comments)

Override with flags: --cache-dir, --geoip-db, --state-file, --audit-log, --never-block-file.

Resolution order (no source arg)

  1. ./caddy-analyzer.json~/.config/…/config.json
  2. Stdin pipe if data is piped
  3. 5 candidates: ./access.log, ./caddy.log, ./caddy-access.log, /var/log/caddy/access.log, /var/log/caddy/caddy.log