Nginx as GeoIP Global LoadBalancer and actual distance from app server

distributed computinggeolocationload balancingnginx

my client is using Magento for it's ecommerce global solution. Main country are US / EU / CN. For now only 1 VM in Italy, serving all traffic.

I would like to create 3 VMs, one for each country, on AWS or Google Cloud, not important at this stage.

maine DNS 1.2.3.4 should point to a www.mydomain.it , where 1.2.3.4 it's a nginx VM (in europe datacenter) configured with MaxMind GeoIP module.

this becouse website has multiple languages and multiple catalog/prices/qty for each country and with nginx i can pass necessary headers and variable to Magento so the cms knows wich language to show to customers from different countries.

My question is: when traffic will hit nginx vm, and it will proxy_pass to eg US server, will the US server actually serve US traffic, or US traffic will flow always via nginx VM so it will lag and slow down?

My goal is to just forward traffic to correspondin VM based on visitor country, so this VM will serve traffic and not the nginx VM

Best Answer

If you read the first answer in this question https://stackoverflow.com/questions/25678049/how-to-setup-global-load-balancing-using-digital-ocean-dns-and-nginx you will see several ways to achieve this, 30x Redirect, Anycast (taking advantage of BGP routing) and Geo-DNS. Route53 (mentioned by @frederico-sierra) is not enough on its own you would have to add CloudFront.