Different origin IPs based on Country


#1

Our company is considering moving one of our high-traffic domains onto Cloudflare, but we have a (somewhat) unique situation…

We have a main “.com” site, however based on Geo-IP we wish to redirect the user to different back end services. We have to do this for local legislation reasons and cannot separate the site out into country tlds nor subdomains.

Effectively, this would be using the Cloudflare platform as a Load Balancer, and route to different servers depending on country.

Can you tell me if this is possible?

Thanks in advanced for any answers.


#2

If you already have software for this (based on country code), there is GeoIP that adds the header “CF-IPCountry” with the country code of the user.


#3

It’s possible to do this at Cloudflare’s edge either using Workers or geo routing in their load balancer product.
Workers can be set to execute on specific paths whereas load balancer is at DNS level, both are billed by usage.

An example worker which does geo routing has been posted here.

There is a help article for geo routing on the DNS load balancer here and billing article here.

Personally I use workers as I can control which routes on my domains are geo routed.