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:
@@ -165,3 +165,5 @@ S3_ENDPOINT=http://garage:3900
|
|||||||
S3_REGION=garage
|
S3_REGION=garage
|
||||||
S3_BUCKET=uploads
|
S3_BUCKET=uploads
|
||||||
GARAGE_CAPACITY=1G
|
GARAGE_CAPACITY=1G
|
||||||
|
|
||||||
|
STPPRIV_LAN_IP=192.0.2.1
|
||||||
|
|||||||
@@ -287,6 +287,12 @@ RECEIPT_WEB_UPSTREAM=100.107.152.119:8765
|
|||||||
# `openssl rand -hex 32`. Changing it needs `docker compose up -d caddy`.
|
# `openssl rand -hex 32`. Changing it needs `docker compose up -d caddy`.
|
||||||
RECEIPT_WEB_TOKEN=
|
RECEIPT_WEB_TOKEN=
|
||||||
|
|
||||||
|
# --- stppriv (priv.DOMAIN) ---------------------------------------------------
|
||||||
|
# The private-tools LXC's LAN IP. Its Caddy asks /api/auth/validate-admin
|
||||||
|
# directly, not via the tunnel, and requests from this IP skip the api rate
|
||||||
|
# limit. Blank matches nothing.
|
||||||
|
STPPRIV_LAN_IP=
|
||||||
|
|
||||||
# --- Partner Radar (radar.DOMAIN) ----------------------------------------------
|
# --- Partner Radar (radar.DOMAIN) ----------------------------------------------
|
||||||
# A separate compose project on this host (adamf/cto, `make stpvm`), whose web
|
# A separate compose project on this host (adamf/cto, `make stpvm`), whose web
|
||||||
# container joins app-network as `radar-web`. Only set this to point
|
# container joins app-network as `radar-web`. Only set this to point
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ RUN set -e; \
|
|||||||
SILVERBULLET_PUBLIC_HOST=silverbullet-public SILVERBULLET_PUBLIC_PORT=3000 \
|
SILVERBULLET_PUBLIC_HOST=silverbullet-public SILVERBULLET_PUBLIC_PORT=3000 \
|
||||||
PYTHON_HOST=python PYTHON_PORT=8000 \
|
PYTHON_HOST=python PYTHON_PORT=8000 \
|
||||||
RECEIPT_WEB_UPSTREAM=127.0.0.1:9 RECEIPT_WEB_TOKEN=validate \
|
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 \
|
CLOUDFLARE_DNS_API_TOKEN=validate-placeholder-token-0000000000000 \
|
||||||
caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile; \
|
caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile; \
|
||||||
done; \
|
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.
|
# On top of the backend's own 5/min.
|
||||||
handle {$BACKEND_ENDPOINT}/auth/login* {
|
handle {$BACKEND_ENDPOINT}/auth/login* {
|
||||||
import limit login 5 1m
|
import limit login 5 1m
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ services:
|
|||||||
- PYTHON_PORT=${PYTHON_PORT:-8000}
|
- PYTHON_PORT=${PYTHON_PORT:-8000}
|
||||||
# A dead port by default, so /receipt/ reads "offline".
|
# A dead port by default, so /receipt/ reads "offline".
|
||||||
- RECEIPT_WEB_UPSTREAM=${RECEIPT_WEB_UPSTREAM:-127.0.0.1:9}
|
- RECEIPT_WEB_UPSTREAM=${RECEIPT_WEB_UPSTREAM:-127.0.0.1:9}
|
||||||
|
- STPPRIV_LAN_IP=${STPPRIV_LAN_IP:-192.0.2.1}
|
||||||
- RECEIPT_WEB_TOKEN=${RECEIPT_WEB_TOKEN:-}
|
- RECEIPT_WEB_TOKEN=${RECEIPT_WEB_TOKEN:-}
|
||||||
# The adamf/cto stack's web container; "offline" while that stack is down.
|
# The adamf/cto stack's web container; "offline" while that stack is down.
|
||||||
- RADAR_UPSTREAM=${RADAR_UPSTREAM:-radar-web:80}
|
- RADAR_UPSTREAM=${RADAR_UPSTREAM:-radar-web:80}
|
||||||
|
|||||||
Reference in New Issue
Block a user