Skip to content

Block xmlrpc.php requests from Cloudflares firewall apart from JetPack

You can block WordPress xmlrpc.php requests from Cloudflare but exclude the JetPack IP addresses by creating a custom firewall rule, attacks on xmlrpc.php are frequent and it is best now disabled as it will be deprecated from WordPress in the future.

However, some of the more popular WordPress plugins such as JetPack still need to access xmlrpc.php so you may need a custom solution to make it available.

Fully Disable xmlrpc.php

You can fully disable xmlrpc.php with a plugins such as perfmatters or Disable XML-RPC or a line of code in your functions.php

add_filter( 'xmlrpc_enabled', '__return_false' );

Check that xmlrpc is disabled with this online validator.

Online Xmlrpc Validator

Partially Disable xmlrpc.php localhost

You can restrict usage by partially blocking access to xmlrpc.php by adding a rule in your .htaccess file

<Files xmlrpc.php>
Order allow,deny
Allow from 192.0.64.0/18
Deny from all Satisfy All ErrorDocument 403 http://127.0.0.1/ </Files>

So only IP addresses in the range of 192.0.64.0/18 can access xmlrpc.php  – which is part of the JetPack IP address range.

Partially Disable xmlrpc.php at Cloudflare but allow JetPack

With the free Cloudflare you can add up to five custom firewall rules, create one to block all IP addresses apart from JetPacks to deny access to any query string that contains xmlrpc.php

Cloudflare Firewall Xmlrpc Rule Create

Create a custom firewall rule

 

 

Cloudflare Firewall Xmlrpc Rule

Add in the range of IP addresses and URI path that contains xmlrpc.php

 

JetPack IP Address Range

The JetPack IP address range is discussed on Github, published at JetPack, but is subject to change which can be verified here, and converted to CIDR notation here.

 

Now you can check the activity of the firewall rule by clicking on the Activity last 24hr link in the rule – also verify your xmlrpc.php is disabled by visiting the online validator.

Leave a Comment





Scroll To Top