Using Cloudflare with Amazon EC2 and load balancers

I decided like this:

I created in the cloudflare, in the DNS table, two CNAME records that point to the dns name of the load balancer generated in aws.

The first record created must contain in the "Name" field, the value "www" with the "content" field pointing to the url of the load balancer in aws. The second record, on the other hand, points to root, containing the value "@" in the "Name" field and "Content" pointing to the same load balancer server in "aws".

See the images below for a better understanding.

enter image description here


I suggest to manage your domain DNS with CloudFlare. Add a CNAME record for your subdomain demo which points to that IP. On CloudFlare Console go to Crypto > Origin Certificates. Create a new one with RSA, then import it to AWS Certificate Manager at us-east-1. For the certificate chain use this. Be sure that Always use HTTPS in Crypto tab is on. After some minutes you should be using your domain pointing to AWS with HTTPS working fine.

That's what I did to make a subdomain to work with an AWS API endpoint with SSL.


You can set your Cloudflare record as a CNAME alias of your ELB's A record

See: https://support.cloudflare.com/hc/en-us/articles/200168986-How-do-I-add-a-Amazon-ELB-Elastic-Load-Balancing-record-to-CloudFlare-


I've tried with the Cname record with target as Load Balancer DNS name, but the website is not secured. If you need static IP for your Load Balancer then use Global Accelerator. It will provide you a static IP. After that create an A record with domain name in cloud flare and content with your Static IP provided by Global Accelerator and the Proxy status must be Proxied.