Search code examples
apachecloudflareapache2.4whitelistapache2.2

Apache 2.4 Whitelist Cloudflare only


I've been trying to get this to work for Apache 2.4

I manually installed Apache 2.4, PHP 5.6, MySql, and MySqli. (I haven't had a problem with mysql since I've only been using MySqli)

I have tried to white list only cloudflare to access my website, but I haven't been having any luck and since their IP list doesn't give me absolutely everything I need, I can't white list them.

I know that I shouldn't white list only cloudflare, but I accidentally shared the IP to someone and they spread it around, and I don't want them using the ip directly, I want them to use cloudflare.

I've tried doing this to white list cloudflare but it hasn't been working:

<Directory "C:/Apache24/htdocs/test"> Options Indexes FollowSymLinks MultiViews AllowOverride all Require all denied Allow from 103.21.*.* Allow from 103.31.*.* Allow from 103.22.*.* Allow from 104.16.*.* Allow from 108.162.*.* Allow from 131.0.*.* Allow from 141.101.*.* Allow from 162.158.*.* Allow from 172.64.*.* Allow from 173.245.*.* Allow from 188.114.*.* Allow from 190.93.*.* Allow from 197.234.*.* Allow from 198.41.*.* Allow from 199.27.*.* </Directory>

I havn't fully understood the jump from 2.2 to 2.4 yet. Could anybody help me out?


Solution

  • If you install the Mod_Cloudflare Apache extension, you can simply add the following to your Apache configuration and all non-Cloudflare traffic will be forbidden:

    DenyAllButCloudFlare
    

    Further reading: