Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Use get_client_ip() in rate limit logging and document storage options

LearningCircuit8c38f9b8a717
diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.py
index 4a752fa7b2..b347c934dc 100644
--- a/src/local_deep_research/web/app_factory.py
+++ b/src/local_deep_research/web/app_factory.py
@@ -128,10 +128,14 @@ def create_app():
# Custom error handler for rate limit exceeded (429)
@app.errorhandler(429)
def ratelimit_handler(e):
+ # Import here to avoid circular imports
+ from .utils.rate_limiter import get_client_ip
+
# Audit logging for security monitoring
+ # Use get_client_ip() to get the real IP behind proxies
logger.warning(
f"Rate limit exceeded: endpoint={request.endpoint} "
- f"ip={request.remote_addr} "
+ f"ip={get_client_ip()} "
f"user_agent={request.headers.get('User-Agent', 'unknown')}"
)
return jsonify(
diff --git a/src/local_deep_research/web/utils/rate_limiter.py b/src/local_deep_research/web/utils/rate_limiter.py
index bf055af693..337b4d0e92 100644
--- a/src/local_deep_research/web/utils/rate_limiter.py
+++ b/src/local_deep_research/web/utils/rate_limiter.py
@@ -35,6 +35,11 @@ def get_client_ip():
# Global limiter instance - will be initialized in app_factory
# Rate limiting is disabled in CI unless ENABLE_RATE_LIMITING=true
# This allows the rate limiting test to run with rate limiting enabled
+#
+# Note: In-memory storage is used by default, which is suitable for single-instance
+# deployments. For multi-instance production deployments behind a load balancer,
+# configure Redis storage via RATELIMIT_STORAGE_URL environment variable:
+# export RATELIMIT_STORAGE_URL="redis://localhost:6379"
limiter = Limiter(
key_func=get_client_ip,
default_limits=["200 per day", "50 per hour"],