captcha: Módulo Captcha de NGINX
Instalación
CentOS/RHEL/RockyLinux/etc. y Amazon Linux son compatibles y requieren una suscripción.
Fedora Linux es compatible de forma gratuita y no requiere una suscripción.
Guías completas de instalación y configuración específicas del sistema operativo disponibles:
Otros sistemas operativos compatibles
dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-captcha
Habilita el módulo añadiendo lo siguiente en la parte superior de /etc/nginx/nginx.conf:
load_module modules/ngx_http_captcha_module.so;
Este documento describe nginx-module-captcha v0.0.1 lanzado el 14 de abril de 2023.
Ejemplo de Configuración:
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) {
# código de captcha inválido
}
}
Directivas:
Sintaxis: captcha;
Predeterminado: ——
Contexto: location
Habilita la generación de la imagen captcha.
Sintaxis: captcha_case on | off;
Predeterminado: off
Contexto: http, server, location
Habilita/deshabilita la ignorancia del caso en el captcha.
Sintaxis: captcha_expire seconds;
Predeterminado: 3600
Contexto: http, server, location
Establece los segundos antes de que expire el captcha.
Sintaxis: captcha_height pixels;
Predeterminado: 30
Contexto: http, server, location
Establece la altura de la imagen captcha.
Sintaxis: captcha_length characters;
Predeterminado: 4
Contexto: http, server, location
Establece la longitud del texto del captcha.
Sintaxis: captcha_size pixels;
Predeterminado: 20
Contexto: http, server, location
Establece el tamaño de la fuente del captcha.
Sintaxis: captcha_width pixels;
Predeterminado: 130
Contexto: http, server, location
Establece el ancho de la imagen captcha.
Sintaxis: captcha_charset string;
Predeterminado: abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789
Contexto: http, server, location
Establece los caracteres utilizados en el texto del captcha.
Sintaxis: captcha_csrf string;
Predeterminado: csrf
Contexto: http, server, location
Establece el nombre de la variable csrf del captcha.
Sintaxis: captcha_font string;
Predeterminado: /usr/share/fonts/ttf-liberation/LiberationSans-Regular.ttf
Contexto: http, server, location
Establece la fuente del texto del captcha.
Sintaxis: captcha_name string;
Predeterminado: Captcha
Contexto: http, server, location
Establece el nombre de la cookie del captcha.
Sintaxis: captcha_secret string;
Predeterminado: secret
Contexto: http, server, location
Establece el secreto del captcha.
GitHub
Puedes encontrar consejos adicionales de configuración y documentación para este módulo en el repositorio de GitHub para nginx-module-captcha.