Enable CAPTCHA Latest Current version only
When your website is under CC attack, it is good to turn on CAPTCHA because CAPTCHA can help you identify the real users.
- This module currently supports three CAPTCHAs, hCaptcha, reCAPTCHAv2 and reCAPTCHAv3. You should choose one and get the Sitekey and Secret from their website.
- Go to
assets/in the project's directory and find the corresponding HTML file, then copy it to any path. For example, if you are using hCaptcha, you should copyassets/hCaptcha.html. - Modify the copied HTML file by changing the string
Your Sitekeyto the Sitekey you got from the CAPTCHA platform. - Modify the nginx configuration.
- Enable CAPTCHA for entire site.nginx
server { waf_captcha on prov=hCaptcha secret=your_secret sitekey=your_sitekey; } - Enable CAPTCHA for a pathnginx
location { waf_captcha on prov=hCaptcha secret=your_secret sitekey=your_sitekey; } - Enable CAPTCHA when request rate is too highnginx
http { waf_zone name=waf size=20m; server { waf_cc_deny on rate=1000r/m duration=1h zone=waf:cc; waf_captcha off prov=hCaptcha secret=your_secret sitekey=your_sitekey; waf_action cc_deny=CAPTCHA zone=waf:action; } }
- Enable CAPTCHA for entire site.
- Restart nginx.
WARNING
If you have some pseudo-static configuration, or some path rewriting configuration, you need to make sure that the path /captcha is not rewritten. Here is a sample modification.
nginx
# BEGIN Before modification
if (! -e $request_filename) {
rewrite ^(.*)$ index.php?s=$1 last break;
}
# END After modification
# BEGIN Before modification
try_files $uri $uri/ index.php?s=$1;
# END After modificationSEO OPTIMIZATION
Enable CAPTCHA will affect search engine crawling, you can use waf_verify_bot to allow certain search engine crawlers.
nginx
waf_verify_bot on;