# 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 (opens new window), reCAPTCHAv2 (opens new window) and reCAPTCHAv3 (opens new window). 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 (opens new window), you should copyassets/hCaptcha.html
. - Modify the copied HTML file by changing the string
Your Sitekey
to the Sitekey you got from the CAPTCHA platform. - Modify the nginx configuration.
- Enable CAPTCHA for entire site.
server { waf_captcha on prov=hCaptcha secret=your_secret sitekey=your_sitekey; }
- Enable CAPTCHA for a path
location { waf_captcha on prov=hCaptcha secret=your_secret sitekey=your_sitekey; }
- Enable CAPTCHA when request rate is too high
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.
# 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 modification
SEO OPTIMIZATION
Enable CAPTCHA will affect search engine crawling, you can use waf_verify_bot to allow certain search engine crawlers.
waf_verify_bot on;