Protect WordPress Login with CloudFlare

The WordPress wp-login.php file is perhaps one of the most used targets by robots and hackers to violate your security.

Therefore, we must implement a series of measures to reduce the probability of our WordPress installation being attacked in this way.

This time I present to you the way to protect your WordPress login with CloudFlare.

The basic requirement is that you at least have an account on Clouflare and that you have your website configured with WordPress.


You’ve probably noticed that in your website’s log there are many calls to the wp-login.php file. This is because you are suffering attacks from robots and hackers trying to violate the security of WordPress and take control of it.

Most of these attacks, from my own experience, come from Russia, China, Pakistan, India and other countries, all of them different from those usually used to legitimately enter WordPress.

Use Cloudflare to block access to wp-login.php

With the free Cloudflare account you have the possibility of creating five firewall rules, in the case of the security of wp-login.php we are going to create one rule.

With this rule, only those calls that come from a single country will be able to access wp-login.php, which in my example is allowed by country.

This rule is to allow only the path containing wp-login.php to be accessed by a specific country. To do this, in the rules form we choose the following:

Assign a descriptive name to the rule -> type a name that is easy to understand. Field -> URI identifier | Operator -> Contains | Value -> wp-login.php AND Field -> Country | Operator -> Not equal to -> Argentina Select action -> Block. Keep.

The view of the expression that is constructed can be displayed, so it should look like this:

(http.request.uri contains "wp-login.php" and eq "AR")

The final code, which in the example is AR, is because I chose Argentina, that is, only calls that come from that country will be able to access wp-login.php.

It should be considered that when “block” is chosen as the action, it means that matching requests are denied access to the site, therefore, all those calls to wp-login.php that do not come from Argentina, because in this example has been configured, the following information will appear in the browser as seen in the image.

In this sense, they will not even access the website, so they will not consume our hosting resources, since in a Cloudflare environment it will protect us from this type of attacks.

That’s why the message in the browser says: “This website is using a security service to protect itself from online attacks.”

As I repeat, it is not the only security measure, but with this the rate of attacks on wp-login.php will be drastically reduced, so in the opposite direction, our WordPress will be safer.

5/5 - 4 votes

Discover more from Politikaperu

Subscribe to get the latest posts to your email.

Discover more from Politikaperu

Subscribe now to keep reading and get access to the full archive.

Continue reading