Geo-DNS Implementation for Routing Users to Nearest Server

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Geo-DNS Implementation for Routing Users to Nearest Server
Medium
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

GeoDNS and Geo-Routing Configuration

GeoDNS directs users to the nearest server at DNS resolution level, before TCP connection. This reduces latency and allows splitting traffic by geographic zones.

GeoDNS Providers

Cloudflare Load Balancing — geo-steering out of the box:

# Cloudflare API: create Load Balancer
curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/load_balancers" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  --data '{
    "name": "api.mysite.com",
    "fallback_pool": "us-east-1-pool",
    "default_pools": ["us-east-1-pool"],
    "region_pools": {
      "ENAM": ["us-east-1-pool"],
      "WNAM": ["us-west-2-pool"],
      "EEU":  ["eu-central-1-pool"],
      "WEU":  ["eu-west-1-pool"],
      "SEAS": ["ap-southeast-1-pool"],
      "NEAS": ["ap-northeast-1-pool"]
    },
    "steering_policy": "geo",
    "session_affinity": "ip_cookie",
    "session_affinity_ttl": 300
  }'

AWS Route 53 Geolocation Routing:

# Terraform
resource "aws_route53_record" "api_eu" {
  zone_id = var.zone_id
  name    = "api.mysite.com"
  type    = "A"

  set_identifier = "eu-users"
  geolocation_routing_policy {
    continent = "EU"
  }

  alias {
    name                   = aws_lb.eu_west_1.dns_name
    zone_id                = aws_lb.eu_west_1.zone_id
    evaluate_target_health = true
  }
}

resource "aws_route53_record" "api_default" {
  zone_id = var.zone_id
  name    = "api.mysite.com"
  type    = "A"

  set_identifier = "default"
  geolocation_routing_policy {
    country = "*" # Default: all other regions
  }

  alias {
    name                   = aws_lb.us_east_1.dns_name
    zone_id                = aws_lb.us_east_1.zone_id
    evaluate_target_health = true
  }
}

AWS Route 53 Latency-based Routing (recommended over geolocation):

# Route traffic not by geography, but by real latency
resource "aws_route53_record" "api_latency_eu" {
  zone_id = var.zone_id
  name    = "api.mysite.com"
  type    = "A"

  set_identifier = "eu-west-1"
  latency_routing_policy {
    region = "eu-west-1"
  }

  alias {
    name                   = aws_lb.eu.dns_name
    zone_id                = aws_lb.eu.zone_id
    evaluate_target_health = true
  }
}

Nginx: Geo-Routing at Application Level

For fine-tuning — MaxMind GeoIP2:

# Install module
apt install nginx-module-geoip2 libmaxminddb-dev

# Download GeoLite2 database
mkdir -p /etc/nginx/geoip
cd /etc/nginx/geoip
curl -L "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key={KEY}&suffix=tar.gz" \
  | tar xz --strip-components=1
# nginx.conf
load_module modules/ngx_http_geoip2_module.so;

http {
  geoip2 /etc/nginx/geoip/GeoLite2-Country.mmdb {
    $geoip2_country_code country iso_code;
    $geoip2_country_name country names en;
  }

  # Map countries to backends
  map $geoip2_country_code $backend {
    default        http://us-backend:3000;
    RU             http://ru-backend:3000;
    UA             http://eu-backend:3000;
    "~^(DE|AT|CH)" http://eu-backend:3000;
    "~^(GB|IE|FR)" http://eu-backend:3000;
  }

  # Map for language version redirect
  map $geoip2_country_code $lang_prefix {
    default  /en;
    RU       /ru;
    UA       /ua;
    DE       /de;
  }

  server {
    listen 80;

    location / {
      # Auto redirect by geo (only first visit)
      if ($cookie_lang_set = "") {
        return 302 $lang_prefix$request_uri;
      }

      proxy_pass $backend;
      proxy_set_header X-Country-Code $geoip2_country_code;
      proxy_set_header X-Real-IP $remote_addr;
    }
  }
}

GeoDNS Testing

# Check from different resolvers (simulating different regions)
dig @8.8.8.8 api.mysite.com       # Google DNS (US)
dig @1.1.1.1 api.mysite.com       # Cloudflare (EU)
dig @77.88.8.8 api.mysite.com     # Yandex DNS (RU)

# Via curl with geolocation simulation (VPN or proxy)
curl -v https://api.mysite.com/health

# Cloudflare trace
curl https://mysite.com/cdn-cgi/trace | grep colo
# colo=AMS → Amsterdam PoP

# Check IP geolocation
curl https://ipapi.co/{IP}/json/ | jq '.country_code, .region'

DNS TTL and Caching

With GeoDNS proper TTL setup is important:

TTL = 30s    → fast failover, high NS load
TTL = 300s   → good balance (recommended)
TTL = 3600s  → reduces DNS load, slow failover

Cloudflare Load Balancing automatically manages TTL on failover.

GeoDNS setup via Cloudflare with two regions — 1–2 working days. Via AWS Route 53 with Terraform — 2–3 days.