Cloudflare provides several free security features that protect your website from attacks, bots, and spam.
Set your security level
- Log in to https://dash.cloudflare.com and select your domain.
- Go to Security → Settings.
- Set Security Level to Medium. This challenges suspicious visitors (known bad IPs) with a browser check before allowing access.
Enable Bot Fight Mode
- Go to Security → Bots.
- Enable Bot Fight Mode. This blocks automated bot traffic from reaching your server.
Enable "I'm Under Attack" mode (for active attacks only)
If your website is under a DDoS attack and is slow or unreachable, you can enable maximum protection temporarily:
- Go to Security → Settings.
- Set Security Level to I'm Under Attack.
- Every visitor will see a 5-second browser challenge before accessing your site.
- Remember to set the security level back to Medium once the attack is over.
Block specific countries or IP addresses
- Go to Security → WAF → Tools.
- Under IP Access Rules, enter the IP address or country you want to block.
- Select Block from the action dropdown and click Add.
Enable HTTPS-only (HSTS)
- Go to SSL/TLS → Edge Certificates.
- Scroll to HTTP Strict Transport Security (HSTS) and click Enable HSTS.
- Set Max Age Header to 6 months and enable Include Subdomains.
Warning: Only enable HSTS if your site is fully running on HTTPS. It is very difficult to reverse once enabled.