区域标识符应该包含在X-Forwarded-For IP中吗?

huangapple go评论80阅读模式
英文:

Should zone identifier be in X-Forwarded-For IP?

问题

当使用Go的http/httputil.ReverseProxy时,在本地地址上监听并通过它进行本地请求时,包括区域标识符的请求会在反向代理添加的X-Forwarded-For头部中出现该区域标识符。(你可以在这里看到它的发生。SplitHostPort会保留区域标识符。)

区域标识符应该出现在XFF IP中吗?这有意义吗?这是一个错误吗?

我对区域标识符的理解不是很清楚,它在使用它的特定机器之外可能没有意义。另一方面,也许如果你想追踪请求的路径,区域标识符是必要的以消除歧义。

英文:

When messing around with Go's http/httputil.ReverseProxy, listening on a local address with a zone, making a request through it locally, including the zone, I've seen that the zone identifier ends up in the X-Forwarded-For header added by the reverse proxy. (You can see it occur around here. SplitHostPort leaves the zone intact.)

Should the zone be in the XFF IP? Does it make sense? Is it a bug?

My not-very-clear understanding of zone identifiers is that it doesn't make sense outside of the particular machine that's using it. On the other hand, maybe if you're trying to trace the path a request took, the zone is necessary to disambiguate?

答案1

得分: 0

在思考了一段时间后,我最终写了一篇关于这个问题的博客文章。这是那篇文章的结论部分:

区域标识应该保留到使用的时候,然后根据IP的具体使用和区域标识对该使用的影响来决定是否保留或去除区域标识。

这意味着反向代理应该在X-Forwarded-For头部中包含区域标识,速率限制器可能应该丢弃它们,并且基于前缀是否有区域标识来进行IP检查。但这只是一些例子,因为IP地址有无数种用途,具体的用途将决定(或至少影响)区域标识的命运。

当然,这个问题是有争议的。如果你想看看其他观点,请查看我在r/ipv6 subreddit上提问时得到的一些评论。如果你有不同的观点或知道其他人对此进行了写作,请告诉我。

英文:

After thinking about this for a while, I ended up writing a blog post about it. Here is the conclusions section of that post:

Zones should be kept until the point of use, and then the decision to keep or strip them should be based on the specific use of the IP and ramifications of zones to that use.

This means that reverse proxies should be including the zone in the X-Forwarded-For header, rate limiters should probably be discarding them, and prefix-contains-IP checks should be based on whether there's a zone in the prefix. But these are only examples -- there are myriad uses of IP addresses, and the particular use will dictate (or at least inform) the fate of the zone.

Of course, this is all debatable. To see some other other opinions, check out the few comments I got when I asked about this in the r/ipv6 subreddit. If you have a differing opinion or know of anyone else having written about this, please let me know.

huangapple
  • 本文由 发表于 2022年3月15日 10:06:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/71476227.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定