Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a website that has users from both Hong Kong and Australia.

Unfortunately, since the server is located in Australia, users from Hong Kong are going to suffer latency problems. Traffic has to go through US before travelling back to Australia.

So I've setup a server in Hong Kong as well, and users using the .hk TLD are going to be redirected to the Hong Kong web server. It shares the same database server with the Australian server but due to aggressive SQL query caching, impact on performance from latency from SQL queries are negligible.

But for users accustomed to the Hong Kong website but have since traveled to Australia, they suffer from additional latency because they go to the .hk site which redirects to the HK server even when they're in Australia. The website is targeted at international students from Hong Kong so this is an significant issue for me.

Instead of redirecting users to the closest web server based on the TLD, how do I redirect users based on their location?

Currently I am using nginx, postgres and Django. Say I know how to estimate users' location based on users' IP addresses, what is my next step? At what level would I work on? What topic should I read up?

share|improve this question
up vote 3 down vote accepted

One option is to use the GeoIP module in nginx and redirect your user to the appropriate site. In this scenario the request will be slow till redirected to the appropriate site.

Second option is DNS. Use Geo DNS based solution. You can read more about it in this thread. GeoDNS doesn't work in case the users use Google DNS or OpenDNS

share|improve this answer
"In this scenario the request will be slow till redirected to the appropriate site. " Do you mean every request from a browser session will be slow until redirected to the appropriate site, or just the first one? – Eric Dec 13 '12 at 4:25
The first request till you redirect it to the appropriate webserver. – Sameer Dec 13 '12 at 5:04

Your Answer


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.