From c81a0c7438ba469fc8f846c6e53f065fc4b19360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 26 Jun 2020 10:54:35 +0200 Subject: [PATCH] fix: Log real IP if the header is given by the reverse proxy --- website/web/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/website/web/__init__.py b/website/web/__init__.py index e0d87a7..45ac3c5 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -63,8 +63,12 @@ app.jinja_env.globals.update(sizeof_fmt=sizeof_fmt) @app.after_request def after_request(response): ua = request.headers.get('User-Agent') + real_ip = request.headers.get('X-Real-IP') if ua: - lookyloo.cache_user_agents(ua, request.remote_addr) + if real_ip: + lookyloo.cache_user_agents(ua, real_ip) + else: + lookyloo.cache_user_agents(ua, request.remote_addr) return response