<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ComparePilot Engineering]]></title><description><![CDATA[ComparePilot Engineering shares practical lessons from building and maintaining WordPress websites and AI-powered tools. I document real implementations involvi]]></description><link>https://comparepilotai.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6ae84f468ebd91f5371a9419/74480ec2-550b-442d-8a03-4b42b5752d06.png</url><title>ComparePilot Engineering</title><link>https://comparepilotai.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Fri, 20 Nov 2026 16:01:08 GMT</lastBuildDate><atom:link href="https://comparepilotai.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How I Use Cloudflare WAF Rules to Protect My WordPress Sites]]></title><description><![CDATA[How I use Cloudflare WAF to protect WordPress, block XML-RPC and sensitive paths, and keep legitimate site traffic working.]]></description><link>https://comparepilotai.hashnode.dev/how-i-use-cloudflare-waf-rules-to-protect-my-wordpress-sites</link><guid isPermaLink="true">https://comparepilotai.hashnode.dev/how-i-use-cloudflare-waf-rules-to-protect-my-wordpress-sites</guid><category><![CDATA[WordPress]]></category><category><![CDATA[cloudflare]]></category><category><![CDATA[waf]]></category><dc:creator><![CDATA[ComparePilot AI]]></dc:creator><pubDate>Mon, 02 Nov 2026 09:42:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ae84f468ebd91f5371a9419/8f16a08c-177c-4f49-962a-600a17946af9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I run several WordPress websites on shared hosting. They're behind Cloudflare, and I use custom WAF rules to filter unwanted requests before they reach the hosting server.</p>
<p>My goal wasn't to create an enormous firewall configuration. I wanted to reduce unnecessary requests to WordPress endpoints, restrict access to sensitive paths, and keep legitimate site functionality working.</p>
<p>Here's how I approached it.</p>
<h2>Blocking XML-RPC Requests</h2>
<p>WordPress includes xmlrpc.php, an endpoint used by some remote publishing clients and integrations.</p>
<p>I don't use XML-RPC for my publishing workflow, so there's no reason to leave it publicly accessible on these sites.</p>
<p>In Cloudflare, I created a custom rule using this expression:</p>
<p>http.request.uri.path eq "/xmlrpc.php"</p>
<p>Action: Block</p>
<p>The rule matches requests to /xmlrpc.php and stops them at Cloudflare.</p>
<p>That's preferable to letting every unwanted request reach WordPress and relying entirely on a security plugin to handle it.</p>
<p>However, I wouldn't recommend unquestioningly applying this rule to every installation. Some tools and integrations still depend on XML-RPC.</p>
<p>Check your integrations before blocking it.</p>
<h2>Restricting Access to Sensitive Files</h2>
<p>Another part of my WAF configuration targets requests for files that shouldn't be publicly accessible.</p>
<p>Examples include:</p>
<p>.env</p>
<p>backup.sql</p>
<p>id_rsa</p>
<p>These filenames often appear in automated requests looking for exposed configuration files, database backups, or private keys.</p>
<p>A simplified Cloudflare expression for these paths is:</p>
<p>( lower(http.request.uri.path) contains "/.env" or lower(http.request.uri.path) contains "/backup.sql" or lower(http.request.uri.path) contains "/id_rsa" )</p>
<p>Action: Block</p>
<p>Using lower() handles capitalization differences in the requested path.</p>
<p>This is an illustrative version of the rule, not a complete export of my production WAF configuration.</p>
<p>I also restrict other endpoints that my sites don't use, including GraphQL.</p>
<p>The important distinction is that I block specific unnecessary paths rather than applying broad restrictions to every request containing suspicious-looking text.</p>
<p>A poorly designed rule can easily block legitimate application traffic.</p>
<h2>Restricting Direct Access to wp-login.php</h2>
<p>My WordPress installations use a customized login URL, so I also restrict direct requests to the default login endpoint.</p>
<p>The basic expression is:</p>
<p>http.request.uri.path eq "/wp-login.php"</p>
<p>Action: Block</p>
<p>This reduces direct access to a common WordPress login target.</p>
<p>But this rule requires particular care.</p>
<p>If your website still uses /wp-login.php for normal authentication, password resets, or plugin integrations, blocking it may prevent legitimate users from signing in.</p>
<p>Don't apply this rule unless your login configuration supports it.</p>
<p>I also use application-level security controls where appropriate. Cloudflare is an additional layer, not a replacement for WordPress security, software updates, or two-factor authentication.</p>
<h2>Keeping the WordPress REST API Accessible</h2>
<p>One mistake I wanted to avoid was treating every WordPress endpoint as suspicious.</p>
<p>The REST API is a good example.</p>
<p>At <a href="https://comparepilot.ai/">ComparePilot</a>, I use WordPress as the foundation for a software research platform with custom functionality, including an AI-powered software advisor.</p>
<p>That functionality depends on legitimate application requests.</p>
<p>Blocking the entire /wp-json/ path would be a terrible approach because it could interfere with the site's own features, integrations, and WordPress functionality.</p>
<p>Instead, I distinguish between endpoints the site actually needs and requests targeting paths that serve no purpose.</p>
<p>The same principle applies to other WordPress installations. A rule that works on one site might break another site with different plugins or integrations.</p>
<h2>Checking What Cloudflare Blocks</h2>
<p>After configuring WAF rules, inspect the requests they match.</p>
<p>Cloudflare provides Security Events, where I can examine available information about blocked and challenged requests.</p>
<p>I pay attention to:</p>
<p>The requested URL path.</p>
<p>The Cloudflare rule that matched.</p>
<p>The action applied to the request.</p>
<p>Whether legitimate functionality could be affected.</p>
<p>Cloudflare's event data can be sampled, particularly on lower-tier plans, so I don't assume the dashboard shows every individual request.</p>
<p>When investigating an unexpected block, I start with the affected URL and the matching rule, not turning off the entire firewall.</p>
<p>I also check essential site functions after security changes, especially login access, forms, API requests, and administrative workflows.</p>
<p>A firewall that blocks legitimate visitors is not properly configured, even if its security dashboard looks impressive.</p>
<h2>What I Learned</h2>
<p>My approach is intentionally simple.</p>
<p>I use Cloudflare WAF to reject requests to unnecessary WordPress endpoints and sensitive paths before they reach shared hosting.</p>
<p>I avoid broad rules that could interfere with legitimate site operations. Each WordPress installation has different dependencies, so I review those dependencies before enabling a restriction.</p>
<p>I also keep Cloudflare's SSL mode set to Full (strict), which validates the origin certificate and helps protect the connection between Cloudflare and the hosting server.</p>
<p>The WAF handles request filtering, while WordPress and hosting security remain separate responsibilities.</p>
<p>I haven't measured a specific performance improvement attributable to these rules, and I wouldn't claim one without proper testing.</p>
<p>The practical benefit is having an additional, configurable security layer in front of the applications I maintain.</p>
<p>If you're running WordPress behind Cloudflare, start with the endpoints your site doesn't need, test each restriction, and review the resulting security events.</p>
<p><strong>Useful documentation:</strong></p>
<ul>
<li><a href="https://developers.cloudflare.com/waf/custom-rules/">Cloudflare WAF Custom Rules</a></li>
<li><a href="https://developers.cloudflare.com/waf/analytics/security-events/">Cloudflare Security Events</a></li>
<li><a href="https://developer.wordpress.org/apis/xml-rpc/">WordPress XML-RPC API</a></li>
</ul>
]]></content:encoded></item></channel></rss>