Before starting this website project, I had limited knowledge about DNS, website protection, or anything related to hosting and security. Surprisingly, setting up these components was pretty straightforward, although it took some time for everything to click.
As we all know, Vercel has been gaining popularity as a hosting service, thanks to its simplicity and user-friendly interface. Naturally, I chose to use it for my website.
I had already made my website public, but I decided to add a contact form and direct all messages to my private Discord channel. This got me thinking about security and how to protect my website from spam and other malicious attacks.
I initially attempted to add a simple Google reCAPTCHA to my contact form, but it proved to be too much hassle to implement on my website, at least for now.
I couldn’t find a simple, straightforward tutorial on setting up the following configuration with a quick Google search, so I decided to write this post to help other beginners like me and to serve as a documentation for myself.
For the sake of this tutorial, I will assume that you already have a domain name from Namecheap and have previously connected it to Vercel.
If not, jorgearuv has a pretty straight forward guide on how to do it
Type | Value |
---|---|
CNAME | cname.vercel-dns.com. |
A | 76.76.21.21 |
CAA | 0 issue “letsencrypt.org” |
Return to the Cloudflare tab.
From “DNS management for your site click Add record
Start with Type and choose CNAME from the dropdown menu
Click Add record again.
Click Add record once more (optional if you removed all the records from Cloudflare).
Scroll down to Cloudflare Nameservers.
Now, wait for the DNS to propagate. This can take up to 24 hours, but it usually happens much faster
Which means that if the visitor is from China, India, Iran, Mexico, Russia or United States and threat score is higher than 5, make them solve simple check box captcha. This will prevent most of the bots from accessing your website.
Read more about Cloudflare Threat Score
There are lots of other rules you can add, but this is a good starting point and there is a lot more to explore in the cloudflare dashboard. But for simple websites this is more than enough.
And there you have it! Setting up your website with Namecheap, Cloudflare, and Vercel might seem a bit daunting at first, but with this guide, I hope you now feel more confident in tackling these tasks. This configuration not only makes your website more secure but also enhances its performance by leveraging Cloudflare’s features.
Remember, the security rules I shared are just a starting point. As you learn more about Cloudflare and the different security features it offers, you can create more customized rules to suit your website’s specific needs. The key is to find the right balance between security and user experience, ensuring that your website remains accessible to legitimate users while keeping malicious actors at bay. Of course, there is no such thing as a 100% secure website, but by following these steps, you can significantly reduce the risk of your website being compromised.
I hope you found this tutorial helpful, and I encourage you to explore more about website security and optimization. As your website grows, it’s essential to continually update the security measures to stay ahead of potential threats.
Good luck, and happy coding!