Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a site, let it be www.site.com/ (ASP NET MVC, but that's doesn't really matter) I have another site, let it be www.secondsite.vi/ (it hosts in Vietnam). The structure of the sites is the same, the data in databases differs.

I want to do following: User navigates to www.site.com/. If his IP address is Vietnamese, then he is taken to www.secondsite.vi/ (but in the URL bar he still sees www.site.com/) Else he is taken to www.site.com/. Also, when user types www.site.com/ from Vietnam, his request shouldn't arrive at the main site's hosting (the ping is too long)

Can you suggest, how can this be done? What are the best practives of doing such things? I heard that it is possible to do this with Amazon Route 53. If so, what should I do to add both sites to it and split IP-address or geoInformation range? Thanks in advance!

share|improve this question

2 Answers 2

1. route53-geo

My understanding is that AWS route 53 does not support geographical DNS presently (but given they roll out new features all the time, this might be out of date already!)

http://www.dnscomparison.com/route53.html "Geographical DNS services are not supported currently but it appears support for this service will be added in the future. You can integrate Route 53 DNS services with any additional Amazon Web Service."

AWS support say the feature is top priority, and coming (circa 2011...); https://forums.aws.amazon.com/thread.jspa?threadID=75241


2. mod_geoip

If you are using apache2/linux you can install a tool such as mod_geoip2 to redirect your users back to the desired geographical instance based on their client IP address.

This stackoverflow question has an example showing how to match on a region, and send the user to the other site with a 302 redirect;

RewriteEngine On  
GeoIPEnable On  
GeoIPDBFile /var/share/GeoIP/GeoIP.dat  
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^VN$  
RewriteRule ^$ http://www.secondsite.vi/$1 [L,NC,QSA]

and then bounce the NOT-vietnam originating IP visitors back to the US hosted site on the other server config;

RewriteEngine On  
GeoIPEnable On  
GeoIPDBFile /var/share/GeoIP/GeoIP.dat  
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^VN$  
RewriteRule ^$ http://www.site.com/$1 [L,NC,QSA]

While it may be undesirable to contact the US server at all in your scenario if your links are very slow, in reality a GET request for "/" is actually only a small amount of request and response data (200-300 bytes each way)-just enough for the "Location: http://www.secondsite.vi." 301 redirect and other response headers. In fact, you could modify the stanzas above to remove one further redirect on the other side, by specifying exactly the "home" page like so;

RewriteEngine On  
GeoIPEnable On  
GeoIPDBFile /var/share/GeoIP/GeoIP.dat  
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^VN$  
RewriteRule ^$ http://www.secondsite.vi/index.html [L,NC,QSA]

As the html in the page served by http://www.secondsite.vi/index.html, has the correct server base, http://www.secondsite.vi/ then all the remaining traffic does not go to the US.


3. There are some commercial service providers for Geo-DNS;

generally you define a bunch of regions, and A, CNAME records are served depending on the originating client IP;

http://www.geoscaling.com/
http://dyn.com/dns/dynect-managed-dns/
http://www.dnsmadeeasy.com/services/global-traffic-director/
http://www.zerigo.com/news/launch-of-geodns-geolocation-load-balancing

(I've not used any of them personally, but I did take a look at these services for a previous requirement, so I'd be interested to know how it works out for you)


4. Run your own Geo-aware nameserver

You are obviously subject to issues to do with caching, and physically locating your DNS servers appropriately. (hence this solution would only be if you had a special situation)

However you can install extensions to the bind DNS server (or dnsmasq etc) that will enable geo-aware for serving your own DNS records;

"HOWTO Implement GeoDNS using BIND & MaxMind" http://phix.me/geodns/

share|improve this answer
    
Thanks for the answer. As i understand, Url rewriting means that the user from Vietnam should first reach www.site.com/ (which can be quite slow) and only after that www.secondsite.vi/ Maybe there is variant when he reaches global DNS server and there his request is transfered to one of the sites based on user IP? It shouldn't be necessary Route 53. Maybe there are some alternatives which has abilities to do this? –  Oleg Jun 15 '13 at 7:03
    
Yes, as long as the user is not totally blocked from the US site, the US site only has to serve back a small amount of data-just the enough for the "Location: http://www.secondsite.vi"; header which is usually only 200-300 bytes. The remainder of the request goes correctly to the fast local server, because all the content of the index.html file correctly points to http://www.secondsite.vi/whatever.jgp –  Tom H Jun 15 '13 at 7:10
    
see point 3. for services providing Geo-aware DNS, which would avoid the need to send an HTTP request first. –  Tom H Jun 15 '13 at 7:16
    
Thanks for such detailed response! I will try to set up some variants. I will try to post here the results of my experience if i succeed. –  Oleg Jun 15 '13 at 9:13

Well, I would recommend to use a CDN rather than do Geocast IP. OVH in France give for 10 euros a month a dedicated IP for example ( so you give always the same A field to your DNS ) but they have multiple servers around the world, and it will automatically link your asian visitor to their closest CDN.

You have 10 backend included, meaning that you can give up to 10 servers, and the local CDN will go to the fastest backend available, so you can enter your US and your Vietnamese server in the different backend, and your Vietnamese visitors will always access the quickest one.

http://www.ovh.com/fr/cdn/

If you don't want to do that, I would recommend DNS Made Easy, but not their "big offer" like Global Traffic Director, rather just their smallest offer (Small Business, 29,95 a year) but with a "DNS FailOver" option ( 4,95$ a year) which always monitor up to 5 backend servers. You can say that if one backend takes more than 1 second to answer to your client, then it automatically goes to the second one, and so, if your Vietnamese server is quickest to answer than your US server, it will be chosen to answer to your Vietnamese visitors.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.