From 5b6cc232e8c953a36635c89e31990b19cff2e740 Mon Sep 17 00:00:00 2001 From: JP Flouret Date: Tue, 19 Mar 2024 14:32:58 -0700 Subject: [PATCH] use x-forwarded-for as client_address --- server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server.py b/server.py index af615c3..1aed1c7 100644 --- a/server.py +++ b/server.py @@ -9,6 +9,9 @@ class MyServer(BaseHTTPRequestHandler): def do_GET(self): + x_forwarded_for = self.headers.get('X-Forwarded-For') + if x_forwarded_for: + self.client_address = (x_forwarded_for.split(',')[0], self.client_address[1]) self.server_version = 'Teapot/1.0.0' self.sys_version = 'Coffee/1.0.0' if self.path == '/healthz':