#5807 enhancement new
something in twisted.web should respect (x-)forwarded-for on the server side
|Reported by:||glyph||Owned by:||sirgolan|
branch-diff, diff-cov, branch-cov, buildbot
Description (last modified by glyph)
This should work vaguely the same way that twisted.web.vhost.VHostMonsterResource works.
- Request.getHost() should return the forwarded-for host rather than the Host:.
- Request.isSecure should return the security of the proto parameter
Like VHostMonster, there should be some configuration required to get into this mode. One mechanism for doing that would be to have a ForwardedForParserResource; however, since the connecting address is quite important, it may also be reasonable to build this directly into Site. Trusting random forwarded-for headers off the internet would not be good, so it should be easy to specify what the address of the expected terminating proxy is.
Also, forwarded-for is a bit more expressive than the vhostmonster idiom in that it can describe multiple hops. This additional information should be exposed through an explicit API - perhaps a new forwardedFor method on Resource that returns an iterable of objects describing the hosts that it was forwarded through.