使用 Geoipdns 和 MaxMind GeoLite 数据为东/西海岸提供服务

发布于 2024-08-18 17:07:18 字数 242 浏览 8 评论 0原文

我想通过我的弗吉尼亚(加利福尼亚)服务器为东(西)海岸的访客提供服务。为此,我计划使用 Geoipdns 和 MaxMind 的 IP 到位置映射。 MaxMind 免费提供两个数据集:GeoLite Country 和 GeoLite City。然而,它们都没有定义东/西海岸地区。一个可能的解决方案是编写一个脚本来组合 GeoLite City 东/西海岸城市的所有 IP 范围,但这听起来有点愚蠢。

这样做的最佳实践是什么?有什么建议或替代方案吗?

I want to serve east (west) coast visitors with my Virginia (California) server. To do so, I plan to use Geoipdns and the IP-to-location mappings from MaxMind. MaxMind provide two datasets for free: GeoLite Country and GeoLite City. However, neither of them has east/west coast regions defined. A possible solution is to write a script to combine all the IP ranges for the east/west coast cities in GeoLite City, but that sounds a little bit stupid.

What is the best practice in doing this? Any suggestions or alternatives?

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

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

发布评论

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

评论(1

狠疯拽 2024-08-25 17:07:18

你想太多了这个问题。

GeoIP City API 为您提供州代码

花十分钟时间,列出要发送到辅助服务器的状态。

在 Perl 中:

my %west_coast_states = qw( ca or wa ut nv ... ); 
my $state = ip_to_state_code();
if ($west_coast_states{$state}) {
    # send West Coast states to West Coast server
} else {
    # all other users sent to East Coast server
}

You're overthinking the problem.

The GeoIP City API gives you a state code.

Spend ten minutes, and make a list of states that you want to send to your secondary server.

In Perl:

my %west_coast_states = qw( ca or wa ut nv ... ); 
my $state = ip_to_state_code();
if ($west_coast_states{$state}) {
    # send West Coast states to West Coast server
} else {
    # all other users sent to East Coast server
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文