captcha: Module Captcha NGINX
Installation
CentOS/RHEL/RockyLinux/etc. et Amazon Linux sont supportés et nécessitent un abonnement.
Fedora Linux est supporté gratuitement et ne nécessite pas d'abonnement.
Guides d'installation et de configuration complets spécifiques au système d'exploitation disponibles :
Autres systèmes d'exploitation supportés
dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-captcha
Activez le module en ajoutant ce qui suit en haut de /etc/nginx/nginx.conf :
load_module modules/ngx_http_captcha_module.so;
Ce document décrit nginx-module-captcha v0.0.1 publié le 14 avril 2023.
Exemple de Configuration :
location =/captcha {
captcha;
}
location =/login {
set_form_input $csrf_form csrf;
set_unescape_uri $csrf_unescape $csrf_form;
set_form_input $captcha_form captcha;
set_unescape_uri $captcha_unescape $captcha_form;
set_md5 $captcha_md5 "secret${captcha_unescape}${csrf_unescape}";
if ($captcha_md5 != $cookie_captcha) {
# code captcha invalide
}
}
Directives :
Syntaxe : captcha;
Par défaut : ——
Contexte : location
Active la génération de l'image captcha.
Syntaxe : captcha_case on | off;
Par défaut : off
Contexte : http, server, location
Active/désactive l'ignorance de la casse du captcha.
Syntaxe : captcha_expire seconds;
Par défaut : 3600
Contexte : http, server, location
Définit le nombre de secondes avant l'expiration du captcha.
Syntaxe : captcha_height pixels;
Par défaut : 30
Contexte : http, server, location
Définit la hauteur de l'image captcha.
Syntaxe : captcha_length characters;
Par défaut : 4
Contexte : http, server, location
Définit la longueur du texte du captcha.
Syntaxe : captcha_size pixels;
Par défaut : 20
Contexte : http, server, location
Définit la taille de la police du captcha.
Syntaxe : captcha_width pixels;
Par défaut : 130
Contexte : http, server, location
Définit la largeur de l'image captcha.
Syntaxe : captcha_charset string;
Par défaut : abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789
Contexte : http, server, location
Définit les caractères utilisés dans le texte du captcha.
Syntaxe : captcha_csrf string;
Par défaut : csrf
Contexte : http, server, location
Définit le nom de la variable csrf du captcha.
Syntaxe : captcha_font string;
Par défaut : /usr/share/fonts/ttf-liberation/LiberationSans-Regular.ttf
Contexte : http, server, location
Définit la police du texte du captcha.
Syntaxe : captcha_name string;
Par défaut : Captcha
Contexte : http, server, location
Définit le nom du cookie captcha.
Syntaxe : captcha_secret string;
Par défaut : secret
Contexte : http, server, location
Définit le secret du captcha.
GitHub
Vous pouvez trouver des conseils de configuration supplémentaires et de la documentation pour ce module dans le dépôt GitHub pour nginx-module-captcha.