Updated X-Forwarded-For to better conform to spec (multiple proxies).
This commit is contained in:
parent
175b9b7338
commit
d5129b5065
1 changed files with 4 additions and 4 deletions
|
|
@ -30,13 +30,13 @@ class HTTPChannelWithXForwardedFor(http.HTTPChannel):
|
||||||
"""
|
"""
|
||||||
Check to see if this is a reverse proxied connection.
|
Check to see if this is a reverse proxied connection.
|
||||||
"""
|
"""
|
||||||
IP = 0
|
CLIENT = 0
|
||||||
PORT = 1
|
|
||||||
http.HTTPChannel.allHeadersReceived(self)
|
http.HTTPChannel.allHeadersReceived(self)
|
||||||
req = self.requests[-1]
|
req = self.requests[-1]
|
||||||
client_ip, port = self.transport.client
|
client_ip, port = self.transport.client
|
||||||
forwarded = req.getHeader('X-FORWARDED-FOR')
|
proxy_chain = req.getHeader('X-FORWARDED-FOR')
|
||||||
if forwarded and client_ip in UPSTREAM_IPS:
|
if proxy_chain and client_ip in UPSTREAM_IPS:
|
||||||
|
forwarded = proxy_chain.split(', ', 1)[CLIENT]
|
||||||
self.transport.client = (forwarded, port)
|
self.transport.client = (forwarded, port)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue