Fix: get the left-most ip when there is multiple (#673)

X-Forwarded-For: <client>, <proxy1>, <proxy2>
get the <client> part when there is multiple proxies or load balancers
This commit is contained in:
Sina Ebrahimi 2021-08-25 23:58:38 +04:30 committed by GitHub
parent 3aa40224a2
commit c89bf6fbf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -241,6 +241,8 @@ class WebhookRequestHandler(web.View):
# For reverse proxy (nginx)
forwarded_for = self.request.headers.get('X-Forwarded-For', None)
if forwarded_for:
# get the left-most ip when there is multiple ips (request got through multiple proxy/load balancers)
forwarded_for = forwarded_for.split(",")[0]
return forwarded_for, _check_ip(forwarded_for)
# For default method