Skip to content

Commit

Permalink
use x-forwarded-for as client_address
Browse files Browse the repository at this point in the history
  • Loading branch information
jpflouret committed Mar 19, 2024
1 parent f465163 commit 5b6cc23
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 5b6cc23

Please sign in to comment.