Cloudflare IP Auto updater


#1

Hello,

Can anyone here have the script or tutorial on how to update cloudflare IP’s automatically? I have created a cloudflare.conf file and included it on my nginx.conf but I don’t know how to update CF ip’s automatically. I know Cloudflare is changing their IP’s but I don’t want to check and change them manually. Thank you.

Note: I’m using the latest Easyengine.


#2

Cloudflare IPs are available as text files:

https://www.cloudflare.com/ips-v4 https://www.cloudflare.com/ips-v6

You can setup a cron-job to run a script.

The script can update your conf file and reload nginx.


#3

Thank you Sir.

Here’s what I did. Please correct me if I’m wrong.

I created a cloudflare.conf file in /etc/nginx/conf.d

My cloudflare.conf file http://hastebin.com/uvoguzawar.nginx

Then I created a new directory for the updater script.

Here’s my updater script http://hastebin.com/gaselakiyu.pl

Tested the script by running this command

$ /usr/local/www/_cron/cloudflare-ip-ranges-updater.sh

$ cat /etc/nginx/conf.d/cloudflare.conf

It worked!

Then I opened crontab

$ crontab -e

00      04      *       *       *       root    /usr/local/www/_cron/cloudflare-ip-ranges-updater.sh >/dev/null 2>&1

I set it to run once a day.

I hope it help others too.


#4

Hello @seyntjim

I hope your query is resolved. I am closing this support topic for now.

Feel free to create a new support topic if you have any queries further. :slight_smile:


#5