Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http/httputil: support RFC 7239 Forwarded header in ReverseProxy #30963
Revival of #20526 which was frozen due to age
I've been using services that make use of Go's Reverse Proxy, and think there's some substantial improvements in the Forwarded header that were overlooked in the original discussion.
Forwarded includes not just previous client IP, it also has the host and protocol, information that is currently haphazardly implemented in a few other non-standard X headers
The protocol and host info also tends to not get nicely appended in the other headers as comma separated lists, and instead just clobbered by the most recent. If you're more than one proxy down, the chances of recovering that info is slim to nil, where as Forwarded would be a combined mechanism to ensure its survival.
Forwarded also specifies the format to put IPv6 addresses in, where as this is also somewhat mixed in implementation of
Considering the RFC provides migration guidelines on how to build a Forwarded header in the presence of an
I've got code and tests for such a feature on a branch, and would be more than happy to open a PR if there's interest.