If you are like me using Cloudflare as your DNS provider for your website and you are using an Amazon EC2 instance as your host, this might be an extra security step you want to implement. You want to do this to protect your server from being directly accessible to the Internet. In this way, only CloudFlare servers will be able to access your web host which significantly improves your security directly.
CloudFlare IPs Amazon EC2 Security Group
Now that you have the list of IP’s that we are going to add to our instance lets dive into this topic. To see which security groups you are using, go to the EC2 Dashboard and then select Instances. Then you want to the right click on your EC2 instance and select networking >> change security groups. The Security Groups box should pop with a list of current groups. You can choose which group to use or if already have you will see the checkbox marked.
Now, after you figure out the security groups in use, it will allow you to edit the security group. To do so go to Network & Security >> Security Groups. This will display a list of the security groups that have been created.
To edit, click on the security group for instance. Then the table at the bottom will have (4) tabs – Description, Inbound, Outbound, Tags. We want the one with restricted Inbound traffic, so click on the corresponding tab and then Edit.
This brings up the Inbound rules table. Here you can choose the Add Rule button at the bottom which makes a new row for your configuration. Make sure you specify HTTP for the Type and Custom IP for the Source. At that point, you just include the Cloudflare IP addresses. You can then expel the Any Source and 0.0.0.0/0 which will confine any web movement with the exception of that originating from Cloudflare. Only add the Cloudflare IP addresses. You can then remove the Source and which will restrict any web traffic except that coming from Cloudflare. At this point, you just include the Cloudflare IP addresses. You can then delete the Any Source and 0.0.0.0/0 which will confine any web movement with the exception of that originating from Cloudflare.
Here is a list of the IP’s from CloudFare which again can be found here.
188.8.131.52/22 2400:cb00::/32 184.108.40.206/22 2405:8100::/32 220.127.116.11/22 2405:b500::/32 18.104.22.168/12 2606:4700::/32 22.214.171.124/18 2803:f800::/32 126.96.36.199/22 2c0f:f248::/32 188.8.131.52/18 2a06:98c0::/29 184.108.40.206/15 220.127.116.11/13 18.104.22.168/20 22.214.171.124/20 126.96.36.199/20 188.8.131.52/22 184.108.40.206/17 220.127.116.11/21