api: a per-client rate limit on the HTTP API, with trusted proxies for X-Forwarded-For

600 /api/ requests a minute per client address (--requests-per-minute), 429 with Retry-After; static UI files and the node's own machine are exempt. The real client behind a reverse proxy is read from X-Forwarded-For only when the connection comes from a --trusted-proxy, taking the last entry that is not itself a trusted proxy. k8s: TRUSTED_PROXY in config.env (the private ranges) is passed as --trusted-proxy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-19 00:35:21 +01:00
co-authored by Claude Sonnet 5.5
parent 5ac02360c4
commit 3799faddcf
10 changed files with 296 additions and 17 deletions
+5
View File
@@ -61,6 +61,11 @@ spec:
for r in ${REGION}; do set -- "$@" --region "$r"; done
unset IFS; set +f
fi
if [ -n "${TRUSTED_PROXY}" ]; then
set -f; IFS=,
for p in ${TRUSTED_PROXY}; do set -- "$@" --trusted-proxy "$p"; done
unset IFS; set +f
fi
exec allmende run "$@"
envFrom:
- configMapRef: