Best way to prevent a WordPress site
from getting hacked is to actually prevent hackers from reaching your site.
And for that, we're going to use Cloudflare firewall.
And for this, we're going to use AI
to help us generate the rules that's going to make everything super easy to set up.
So let's get started with this tutorial.
The idea is to use Cloudflare for the firewall.
Now, the good thing about it is that it's
not going to affect your website speed or the user experience.
Now, to do this,
we're going to head on over to Security WAF, which is the website application
firewall, and this is where we are going to create the rules.
Now, in order to use Cloudflare, we need to connect our domain
to Cloudflare, so it routes the traffic through it.
That way the firewall can work.
Now, take for example, I'm using Hostinger, which is our sponsor,
and to connect it to Cloudflare, I would have to go into the domain,
manage it, and this would be the same case for other hosting providers.
And in the named servers is where I'm going to change it.
These named servers are going to be
provided by Cloudflare once you add the domain.
You change these, you save it, and now it's going to route traffic
through Cloudflare, and that way we can use the firewall.
Now, if you want to grab a plan right now,
I do recommend the shared hosting from Hostinger, which is this one right here.
Go into Web Hosting.
They have several plans available,
and obviously the premium hosting one, which is the middle one,
is the recommended one, which is $2.99 for each month.
Now, if we add it to the card, there are several options that I want
to show you before you jump into each one of these plans.
Now select the one that fits best for you.
Now, once you are here, you're going to be able to select from one to 48 months.
I would recommend jumping into 48 months, not because I want you to pay more,
because that's where you lock in the $2.99 for the 48 months.
Plus the renewal price is cheaper with 48 months, so it's recommended.
Now, once you select it, the 48 months, the price is $143.52 as of this video.
But there's an extra discount coupon code
that I'm going to show you that is SaaS Master.
We go ahead and apply it and we're going
to see this price updated to $129.17. So take advantage of the coupon code
and the link that I'll be provided in the description.
So check it out.
Okay, so let's get started with the firewall rules.
I told you in the beginning this was going
to be easy and that we are going to use AI for this.
That way it's going to be easier for us to generate our customized rules because
not all rules fit our needs because we can go into a website and see rules
for firewalls, but that might be a general use case.
We have personal cases where we need
different type of rules and AI is going to help us with this.
And for that, we're going to use ChatGPT..
So let's get started with this.
Once we're here on WAF,
we're going to create a rule and let's go ahead and name our rule.
For example, I'm going to name it PreventHackWP.
You can name it whatever you want.
It's just the name so you can locate it later on.
We can create each one of these rules,
which would be complicated if you are not experienced like some of us are.
We're going to start we can do it through this.
For example, the URL path equals contains,
I don't know, WP config, which is one of the folders that you don't
want hackers to reach because they have no business in there.
But we're going to make this easier.
We're going to use ChatGPT for this.
And for that, we're going to use the expression preview.
We're going to edit this because ChatGPT is going to give us this rule and we're
just going to paste it in here and it's going to be done for us.
So let's askChatGPT. for this and let's
ask for some suggestion for rules to prevent WordPress hacking.
Okay, so I just asked the first prompt, which is provide me some WAF rules I can
use in Cloudflare to prevent my WordPress site from getting hacked.
So it's going to provide me some examples of things that I should be adding.
It's not going to provide me the rules yet.
We're just getting started with this.
So this is what I would recommend to get started.
So ChatGPT knows what we want from this. Okay?
So first of all, it's telling us enable
CloudF layers Manage Rules set, which is what we're going to do in a bit.
So it's going to give us several examples.
Next, we're going to ask it to write these rules in a way that we can
copy and paste it over there on Cloudflare.
Okay, so it just finished and it gave us
all these suggestions which are super useful.
Okay, so let's tell it to give us a rule,
an expression where you can just copy and paste into Cloudflare.
Okay, so let's ask it. Okay, here we go.
Let's see if it understands what we're asking it.
So this is one of the rules that we can add.
Let's go ahead and test it really quickly.
But I'll ask it to combine it because we don't want to add each one of these.
Okay, so I've added it here.
I can go back to the expression or I can go edit the expression builder.
See how it added this one?
Url path equals this file extension,
which again, hackers should not be accessing and just by copying and pasting.
Okay, so it works.
What we want to do is combine some of these.
We added in one rule. Why?
Because if you're using the free version
of CloudFair, we have a, I think it's five maximum rules that we can use.
We don't want to use one single rule for each one of these.
We can go ahead and combine them.
Let's go ahead and ask it. Here we go.
Combine these into one rule so I can paste it into expression builder.
Let's see if it understands. There we go.
It's working.
We got the rule that we can copy
and paste, but it was too complex, so I had to ask it again.
I said the expression builder is not receiving this command.
Provided clean code, I can copy and paste into Cloudflare.
And it did understand.
It told me it was too complex, so it wrote for me a simpler one.
Let's go ahead and add it here in the expression builder.
Here we go. Now it's working.
It added all of these rules for us without any complexity.
That's pretty simple, right?
Now, let's go ahead and deploy this.
What we want to do is the action we can block or we can manage the challenge.
If you want to manage the challenge, it'll sometimes block the users and make
them hit that little I'm not a robot tick thing.
But if not, you can just go ahead and straight block.
So it'll depend how you want to use this.
So with this rule, we're able to prevent
hackers from reaching your site, certain files.
Now we can create more rules.
We don't have to stick to one.
We can go ahead and add another one.
And it could be a rule, for example, for allowing certain countries.
So for example, let's go ahead and ask ChatGPT..
Okay, so we're going to go ahead going to test this one out.
What I want to do is prevent, for example,
the country, Russia and China from accessing the site with a rule.
This is just an example saying, you know what?
I don't want traffic coming from those countries.
Maybe there's a lot of hacking attempts
and you have no reason to sell products, for example, in those countries.
It's based on US or Mexico or whatever country.
This could be an example. Let's grab this code and test it out
and we're going to use the expression builder.
Let's go ahead and paste it and let's go ahead and view it.
Here we go.
Country equals Russian Federation and country equals China.
You can choose the action.
Now, you don't have to specifically just go right up, go ahead and block.
You can go ahead and do a Manage challenge.
That way, if it's known that they are hackers or trying to reach the site too
many times, it's going to do a Manage challenge.
It's not blocking it completely,
but it will prevent it from trying to do a force attack, or if they have a bad
reputation, it's going to do a Manage challenge.
We're going to go ahead and deploy this if we like.
In this case, I won't do it, but it's that easy.
The idea is to use ChatGPT to provide us
these rules so we don't have to do these manually.
In this case, instead of doing each one of these, it could be complex for some
of these, but it's going to do it super easy with ChatGPT..
I'll give you one last example for a complex one.
For example, threat score.
For the threat score, let's go ahead and tell it to give us something.
Now we got the threat score.
Let's go ahead and copy this and use it over here.
Let's use the expression builder and here we go.
If the threat score is greater than 20,
then it's going to Manage Challenge or Block however you want to use it.
But let's ask it for more information on the threat score.
Okay, so what I'm going to ask it is, what number of threat score is more subtle?
Just to know if it's higher or lower, it's going to do it.
Okay, here we go.
You can see, keep in mind that increasing
the threats hold might allow more potential malicious traffic.
The higher the number is,
the more subtle it's going to be and less blocking that it's going to do.
So that's how easy it is to use.
Now, the idea is to use ChatGPT and start
playing around with it to ask it to be more customized with your own type
of needs to create the firewall rules in Clouds there.
But it's as easy as that.
Now, don't forget to check out the deal that's going on in Hostinger
with the extra discount coupon code that I'm providing.
And that will be also provided in the link in the description.
I thank you all for watching and that's a wrap.