Easy to use

This guide will demo how to config cloudflare IP whitelist.

Go to the /etc/nginx directory and edit cloudflare-allow.conf file:
cd /etc/nginx/
vi cloudflare-allow.conf
Edit the following configuration into it, just like below:
# IPv4
allow 173.245.48.0/20;
allow 103.21.244.0/22;
allow 103.22.200.0/22;
...

Save and close it.

Now edit nginx configuriton:
location / {
        include /etc/nginx/cloudflare-allow.conf;
        deny all;
}

Finally, Apply configuration

nginx -s reload