Bypassing CF DNS for specific countries

#1

Hi,

Scenario:
My host’s server is in Singapore.

Without CF, the server response time for visitors from Singapore & India is very good (below 100ms).
WIth CF on, the server response time is significantly higher.
However, with CF on, I get better response time for visitors from North America/Europe.

Question:
Is there any way to have CF provide DNS/cache service to North America/Europe,
but use original host’s IP when the visitor is from Singapore/India?

Thanks.
BB

0 Likes

#2

No way that I can think of.

0 Likes

#3

Thanks.

Do you know what would be the best setup so that visitors from India/Singapore get better response time, and at the same time - visitors from other continents do as well?

0 Likes

#4

You could serve your site out on two different ‘vhosts’ - i.e. have it served on both www.example.com and on sg.example.com (for Singapore), say. Then have the www subdomain proxied by Cloudflare (orange cloud) and the sg subdomain direct (grey cloud).

You’d need to set up a redirect on your web server so that visitors from Singapore are sent to their dedicated subdomain, but that’s easily done as Cloudflare pass you a geolocation header - CF-IPCountry.

So now your server set up is to listen on both www.example.com and sg.example.com and have a little redirect that checks if CF-IPCountry == “SG” in your server config (.htaccess, say).

Repeat this for India, too.

The first hit on the site would still have a little delay being routed via Cloudflare but once that initial redirect was done, you’d be fine.

Obviously if Singapore/India is your main audience, flip it around and have them served on www.example.com and international visitors on int.example.com, whatever makes more sense.

1 Like

#5

Hi Saul,
Really appreciate your suggestion. Very good solution.
My only concern is that I would like visitors from Singapore/India to share the same url to a page that others in North America would do.
From the solution above, it appears different people from would end up sharing different urls.
eg. sg.domain.com/aboutus
And domain.com/aboutus

0 Likes

#6

Yeah, there’s no easy way around that really. Domain.com is going to have to either resolve to the Cloudflare IPs in which case you’re using them, or your real backend IPs to bypass them, you can’t really return both.

However if your redirect contains the request path there’s not really any problem having domain.com move a user over to sg.domain.com from a technical standpoint. You can still brand as domain.com etc. and traffic will still hit the correct page after the redirect.

I mean if it’s good enough for Google (when I type google.com I get put on google.co.uk in the UK and google.com.au in Australia but I still know them and refer to them only as google.com) then I’d be happy with it.

But yes, it’s not perfect.

0 Likes