Create Elastic IP
To create Elastic IP for your Elastic Compute Cloud (EC2) instance, go to Elastic IPs on the left menu and click [allocate new address]. A new address will be allocated to you, then associate the address to your EC2 instance.
The reason why we are creating an Elastic IP is that the IP address assigned to your server is not permanent and it changes each time you restart your EC2 instance. You would not want to keep changing your IP address in Cloudflare each time your server rebooted.
Configure Security Group
Within EC2, under instances, select the Ubuntu instance with the IP address 22.214.171.124. Within the description tab, click the security group named launch-wizard-2, it will bring you to the security group of your EC2 instance.
At the security group settings, inbound tab, click edit. Click add rule and add a type HTTP, then click save. This allows inbound HTTP traffic into your Ubuntu instance.
SSH into your Ubuntu server to install Apache. Type the following command to install. Once completed, open your web browser and navigate to 126.96.36.199. If you had configured your security group correctly and successfully installed Apache, you should see the Apache default page.
sudo apt-get update sudo apt-get install apache2 -y
Configure Cloudflare Domain Name Server (DNS)
In Cloudflare, click DNS at the top menu. Key in the name of your domain, enter the IP address of the elastic IP allocated for your EC2 instance. Click [add record] and wait for a minute or two for the domain name server to resolve your domain to the specified IP.
Test Cloudflare DNS
To test if you had configured your Cloudflare correctly. Open your web browser and navigate to domain created. In my scenario, I will be navigating to test.oofnivek.com. If you had successfully configured Cloudflare, you should see the Apache default page.