Files
stpweb/caddy/Dockerfile
T
adamfandClaude Opus 5.5 65f2408ad4 Caddy: let stppriv's admin gate skip the api rate limit
stppriv's Caddy asks /api/auth/validate-admin for every request it
gates, all from its one LAN IP, which would exhaust the 30/s per-IP api
bucket on a SilverBullet page load. Requests from STPPRIV_LAN_IP to that
one path go straight to the backend. Public traffic always arrives from
cloudflared's address, so it cannot match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 13:53:41 +00:00

34 lines
1.7 KiB
Docker

# Caddy plus the Cloudflare DNS and rate-limit plugins. caddy-ratelimit is
# pinned to a commit (no usable release), so Renovate leaves it; bump by hand.
# Builder and runtime tags move together.
# The last RUN validates the config for both modes, so a bad config fails the
# build before any running container is replaced.
FROM caddy:2.11.9-builder AS builder
RUN xcaddy build \
--with github.com/caddy-dns/[email protected] \
--with github.com/mholt/caddy-ratelimit@5625512f24f6f59d6f64fb3aafe5eecff0b286db
FROM caddy:2.11.9
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY Caddyfile routes.caddy /etc/caddy/
COPY sites/ /etc/caddy/sites/
# A log directory that can't be opened stops the config loading.
RUN mkdir -p /var/log/caddy /srv/www /srv/uploads
RUN set -e; \
for site in prod dev; do \
echo "caddy validate (CADDY_SITE=$site)"; \
env XDG_DATA_HOME=/tmp/validate XDG_CONFIG_HOME=/tmp/validate \
CADDY_SITE=$site DOMAIN=example.com EMAIL=[email protected] \
BACKEND_HOST=backend BACKEND_PORT=8080 BACKEND_ENDPOINT=/api \
ICECAST_HOST=icecast2 ICECAST_PORT=8000 \
GITEA_HOST=gitea GITEA_PORT=3000 \
SILVERBULLET_HOST=silverbullet SILVERBULLET_PORT=3000 \
SILVERBULLET_PUBLIC_HOST=silverbullet-public SILVERBULLET_PUBLIC_PORT=3000 \
PYTHON_HOST=python PYTHON_PORT=8000 \
RECEIPT_WEB_UPSTREAM=127.0.0.1:9 RECEIPT_WEB_TOKEN=validate \
STPPRIV_LAN_IP=192.0.2.1 \
CLOUDFLARE_DNS_API_TOKEN=validate-placeholder-token-0000000000000 \
caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile; \
done; \
rm -rf /tmp/validate /var/log/caddy/*