From a702894e0e70c91d172941c346b2cf5e56413199 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 8 May 2020 11:38:58 -0700 Subject: [PATCH] middleware: Stop using X_REAL_IP. The comment was wrong, in that REMOTE_ADDR is where the real external IP was; X_REAL_IP was the loadbalancer's IP. --- zerver/middleware.py | 5 +---- zerver/views/report.py | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/zerver/middleware.py b/zerver/middleware.py index b91f7b38c8..373bd64108 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -276,10 +276,7 @@ class LogRequests(MiddlewareMixin): # intends to block, so we stop here to avoid unnecessary work. return response - # The reverse proxy might have sent us the real external IP - remote_ip = request.META.get('HTTP_X_REAL_IP') - if remote_ip is None: - remote_ip = request.META['REMOTE_ADDR'] + remote_ip = request.META['REMOTE_ADDR'] # Get the requestor's identifier and client, if available. try: diff --git a/zerver/views/report.py b/zerver/views/report.py index e8bb21b18c..b802027278 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -113,9 +113,7 @@ def report_error(request: HttpRequest, user_profile: UserProfile, message: str=R version = None # Get the IP address of the request - remote_ip = request.META.get('HTTP_X_REAL_IP') - if remote_ip is None: - remote_ip = request.META['REMOTE_ADDR'] + remote_ip = request.META['REMOTE_ADDR'] # For the privacy of our users, we remove any actual text content # in draft_content (from drafts rendering exceptions). See the