After you set up your account with CloudFlare, add your WordPress site, download the WordPress plug-in for Cloudflare and fill in the blanks on the set-up screen, and switch your DNS over to Cloudflare, you may notice that CloudFlare recommends one additional step: Whitelisting CloudFlare IP addresses.
For some reason, though, the CloudFlare plug-in does not handle this for you, even though the Cloudflare IP addresses are in the plug-in code, so you’ll have to do it yourself.
The “manual” way of doing this is to edit your .htaccess file (which can be tricky) to allow connections from CloudFlare IP addresses. If you do have the ability to edit your .htaccess file, this is actually fairly easy to do because CloudFlare offers a page with the necessary Apache directives. Of course, any time you edit your .htaccess file, you have to make certain you don’t hose your WordPress directives, or other directives that allow your site to load and run.
There is an easier way, though, involving JetPack (which you should be using anyway).
In JetPack settings, scroll down to “Protect,” and click “configure.” On the protection page, there’s actually a text field for entering IP addresses to whitelist. Imagine that.
The catch is that you do not enter Apache directives here, so instead of entering:
Allow from 220.127.116.11/21
You would enter an IP range thusly:
You don’t need to enter “Allow from,” just the IP or IP range.
So on the Protect settings page, you would enter the IP4 CloudFlare IP addresses like this:
18.104.22.168-22.214.171.124 126.96.36.199-188.8.131.52 184.108.40.206-220.127.116.11 18.104.22.168-22.214.171.124 126.96.36.199-188.8.131.52 184.108.40.206-220.127.116.11 18.104.22.168-22.214.171.124 126.96.36.199-188.8.131.52 184.108.40.206-220.127.116.11 18.104.22.168-22.214.171.124 126.96.36.199-188.8.131.52 184.108.40.206-220.127.116.11 18.104.22.168-22.214.171.124 126.96.36.199-188.8.131.52
The Protect settings page helpfully tells you what IP address you are visiting from, so you can also whitelist your own IP address, should you wish.