Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use Route 53's latency based routing in conjunction with Cloudflare?

I've registered a domain through Route 53. This is what my records look like in Route 53:

fakeelias.ca.         A    #.#.#.#

fakeelias.ca.         NS   brett.ns.cloudflare.com 
                           roxy.ns.cloudflare.com

fakeelias.ca.         SOA  ns-####.awsdns-17.org. awsdns-hostmaster.amazon.com. 

staging.fakeelias.ca. A    #.#.#.#

www.fakeelias.ca.     A    ALIAS fakeelias.ca. (z1pgzi762j7wmn)

To get the Cloudflare working in front of my s3 buckets I had to replace the NS entry with the what Cloudflare gave me and now my CNAME mappings for my buckets work through Cloudflare.

What's not working are my paths fakeelias.ca, www.fakeelias.ca and staging.fakeelias.ca.

I want to use latency based routing through Route 53 for those so that fakeelias.ca will point to the nearest NGINX server. staging.fakeelias.ca will point to my NGINX staging server. Are the NS entries for Cloudflare messing this up? I'm kinda new to this DNS stuff.

like image 366
Josh Elias Avatar asked Feb 10 '23 19:02

Josh Elias


1 Answers

Update for 9/2016:

Cloudflare has now released their Traffic Manager feature that can do global load balancing and health checks: https://blog.cloudflare.com/cloudflare-traffic-manager-the-details/


Yes, you can use Cloudflare as the CDN edge/proxy and Route53 for the routing behind it.

You need to have 2 different domain names for this to work, one for Route53 and the other with Cloudflare.

  1. Setup Route53 to route your queries to the servers you want using a record set (like routing.example.com pointing to US and Europe servers). Read Route53 documentation for details on how to do this. This domain will only be accessed by Cloudflare so it can be any random cheap name.

  2. Setup Cloudflare with the public domain for your website and enter a CNAME record pointing to the Route53 domain name you setup above. Cloudflare's servers will then follow the CNAME and be routed to the right server using Route53 rules. Ensure that Cloudflare proxying (the orange cloud) is enabled.

Each Cloudflare datacenter will lookup and cache the DNS responses locally so geographic routing will work fine. Even if you aren't using Cloudflare to proxy the traffic to your site, there are still benefits in using them

  • CloudFlare's DNS servers are some of the fastest which means less latency and better performance for your users.
  • If you have lots of traffic, Cloudflare will save money since you only have to pay for the lookups that are then cached by CF servers, while their free DNS service takes care of the rest.
  • DNS has lots of security risks and Cloudflare supports DNSSEC which helps make sure your domain isn't damaged or redirected while being protected from DDOS (which can happen to DNS too).

I used this setup for both geographic load balancing (sending to the closest server) as well as global round-robin (spreading load randomly) on a service doing billions of requests a month and everything worked well.

like image 58
Mani Gandham Avatar answered Feb 12 '23 14:02

Mani Gandham