Cloudflare HTTP_CF_IPCOUNTRY有时会退回错误的国家

发布于 2025-02-09 19:14:56 字数 375 浏览 3 评论 0原文

我正在尝试通过标题HTTP_CF_IPCOUNTRY从CloudFlare获取访问者的国家代码。 当我使用此信息时,我会收到我正在访问网站的正确国家代码,尽管此代码有时会更改。

例如;我的国家代码应该是LK,在整个网站上都在整个会话中都正确显示,但是有时候,如果我导航到子页面,请在隐身 /不同的浏览器中打开网站,从另一台计算机上更改网络连接或查看,代码可能会更改,有时我会为访问的每个页面获得不同的代码。

国家代码更改没有模式,因此我为什么使用“有时”一词,并且似乎是随机的。

我没有在Internet连接之上使用任何代理或VPN,并且每当出现问题时我的IP都保持不变。

有人必须淡化这些代码可能会改变的想法吗?

I'm trying to get the visitor's country code from Cloudflare through the header HTTP_CF_IPCOUNTRY.
When I use this, I receive the correct country code I am visiting the site from, although this code can change at times.

For example; my country code is supposed to be LK which is shown correctly throughout my site for majority of a session, but sometimes if I navigate to a subpage, open the site in incognito / different browser, change network connections or view from another machine, the code may change, sometimes I get a different code for each page I visit.

There is no pattern to the country code changing hence why I use the word "sometimes" and seems to be random.

I'm not using any proxies or VPNs on top of my internet connection, and my IP remains the same whenever the issue arises.

Does anyone have to faintest idea as to why these codes might be changing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪淡了忧伤 2025-02-16 19:14:56

整个by-IP地理位置的技术基础相当薄弱,不是一门精确的科学。它只是基于大数据积累,所有大数据积累都有一定的错误余量。您可能会使用ISP,有时可能会在内部,有时甚至通过另一个IP来路由请求,并且一个IP与一个国家相关联,但另一个IP恰好与该大型数据库中的另一个国家 /地区相关联,正确或错误地是错误的。或为什么CloudFlare可能会看到您的请求有时或另一个IP的其他因素,以及/或为什么在其数据库中可以将该IP列为一个国家或另一个国家。也许IP最近发生了变化,并且该更新的数据库尚未将其推广到CloudFlare的所有边缘服务器,有时您会使用过时的GEO-IP数据库击中服务器。

您刚刚找到了一个边缘盒,因为……原因。

The entire technical foundation for geolocation-by-IP is fairly weak and not a precise science. It's just based on large data accumulations, and all large data accumulations have some margin of error. It's entirely possible you're on an ISP which may sometimes route requests through one IP internally and sometimes through another, and that one IP is associated with one country but the other happens to be associated with another country in that large database, rightly or wrongly. Or any number of other factors why CloudFlare may see your request coming from one IP or another at times, and/or why that IP may be listed as one country or another in their database. Maybe the IP changed recently, and that updated database hasn't been rolled out to all of CloudFlare's edge servers yet, and sometimes you're hitting a server with an outdated geo-IP database.

You've just found an edge case that flipflops because… reasons.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文