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]>
This commit is contained in:
@@ -26,6 +26,7 @@ RUN set -e; \
|
||||
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; \
|
||||
|
||||
@@ -66,6 +66,20 @@ handle {$BACKEND_ENDPOINT}/ws* {
|
||||
}
|
||||
}
|
||||
|
||||
# stppriv's admin_gate checks every one of its requests here from one LAN IP,
|
||||
# so it would exhaust the per-IP api limit. Public traffic always arrives from
|
||||
# cloudflared, so it can never match.
|
||||
@stppriv_gate {
|
||||
path {$BACKEND_ENDPOINT}/auth/validate-admin
|
||||
remote_ip {$STPPRIV_LAN_IP}
|
||||
}
|
||||
handle @stppriv_gate {
|
||||
uri strip_prefix {$BACKEND_ENDPOINT}
|
||||
reverse_proxy {$BACKEND_HOST}:{$BACKEND_PORT} {
|
||||
import proxy
|
||||
}
|
||||
}
|
||||
|
||||
# On top of the backend's own 5/min.
|
||||
handle {$BACKEND_ENDPOINT}/auth/login* {
|
||||
import limit login 5 1m
|
||||
|
||||
Reference in New Issue
Block a user