简体   繁体   中英

Redirect domain dns to different server by country ip

I have one domian with this name "example.com" but i want any time user come to my domain redirect to different server by user country ip

user ip = 192.168.1.1 : USA Go To "example.com" with ip => 127.0.0.1 in USA

user ip = 192.168.1.2 : Canada Go To "example.com" with ip => 127.0.0.2 Canada

You'll need to set up a HTTP(S) Load Balancer

The following quote was taken from the above link:

Creating a cross-region load balancer

You can use a global IP address that can intelligently route users based on proximity. For example, if you set up instances in North America, Europe, and Asia, users around the world will be automatically sent to the backends closest to them, assuming those instances have enough capacity. If the closest instances do not have enough capacity, cross-region load balancing automatically forwards users to the next closest region.

See the following link for a guide on how to set this up

Creating Cross-Region Load Balancing

Answering via mobile phone device.

First off you will need a database of ip addresses to country, i looked into this some years ago and found they are charged, some are free but its accuracy arent as good as premium databases

Then once you have this You can either do a database table of country iso code to a php or asp page

Or You could do a switch statement on an isolated php or asp page that you include into the page, allowing you to reuse elsewhere in your website without endlessly copying and pasting scripts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM