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