There are many times I wish I could just blame Canada for many of the issues that happen. Lately, many parts of Snat.co.uk has been a target of DDOS attacks and it always seems to start in Canada.
Also, I got an order for a product that I was selling and someone brought it however the person ended up being a scammer (Asking PayPal to refund, then trying to get me to refund it as well “outside of PayPal”) and the details that were recorded was that the person came from Canada.
Now, that aside and that Canada is a nice place (Or so I hear, still don’t wanna go there 😉 ) but after this, I decided that enough was enough so I decided to look into many ways to block different countries (Not Canada) but other very high-risk places like Iran so I decided to have a look into some solutions and I have found three ways that work the best.
The first way was blocking them via .htaccess and that is a failsafe method as it will just work (Apache is needed) however the list IPs can change and therefore you need to update it often (It is possible to do this automatically but that is a post for another day).
Once you have a list of all the IP addresses for the country you want to block (Have a look on Google) just put the following code into your .htaccess file (127.0.0.1 is the part you want to change).
deny from 127.0.0.1
allow from all
You also might want to put comments so you know which one is which (# is used for comments). The next method was using MaxFraud and PHP to block them. I won’t go into the PHP code that I used (A post for another day) but it worked just as well as .htaccess as I only needed to re-download the MaxFraud database when it was updated (Or use their API which I believe they have).
My advice, use more than one method to block any users you don’t want accessing your site.
Seeing the title topic says Blame Canada and I am a massive South Park fan (Just look at my name), here is a link to a post that I posted at some point in this blog life called – Robin Williams – Blame Canada (South Park).
Need to reference?
Ellis, M. (2008). All the time I wished I could blame Canada. [online] Snat's Narratives & Tales. Available at: https://snat.co.uk/rants/all-the-time-i-wished-i-could-blame-canada.html [Accessed 07 Dec 2023].
Steam Key Giveaway!
Every month on the final Sabbath, I take a random comment that has been posted that month and for that lucky winner they will win a random key from G2A! Join Discord for any questions or leave a comment!