Fix traceback in x-forward-for in cases of localhost
This commit is contained in:
parent
ea802b4567
commit
6c1a77eecc
1 changed files with 9 additions and 8 deletions
|
|
@ -70,14 +70,15 @@ class HTTPChannelWithXForwardedFor(http.HTTPChannel):
|
||||||
Check to see if this is a reverse proxied connection.
|
Check to see if this is a reverse proxied connection.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
CLIENT = 0
|
if self.requests:
|
||||||
http.HTTPChannel.allHeadersReceived(self)
|
CLIENT = 0
|
||||||
req = self.requests[-1]
|
http.HTTPChannel.allHeadersReceived(self)
|
||||||
client_ip, port = self.transport.client
|
req = self.requests[-1]
|
||||||
proxy_chain = req.getHeader("X-FORWARDED-FOR")
|
client_ip, port = self.transport.client
|
||||||
if proxy_chain and client_ip in _UPSTREAM_IPS:
|
proxy_chain = req.getHeader("X-FORWARDED-FOR")
|
||||||
forwarded = proxy_chain.split(", ", 1)[CLIENT]
|
if proxy_chain and client_ip in _UPSTREAM_IPS:
|
||||||
self.transport.client = (forwarded, port)
|
forwarded = proxy_chain.split(", ", 1)[CLIENT]
|
||||||
|
self.transport.client = (forwarded, port)
|
||||||
|
|
||||||
|
|
||||||
# Monkey-patch Twisted to handle X-Forwarded-For.
|
# Monkey-patch Twisted to handle X-Forwarded-For.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue