开发者

Serving east/west coasts with Geoipdns and MaxMind GeoLite data

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 mappi开发者_如何学Pythonngs 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?


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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜