Zum Inhalt

captcha: NGINX Captcha Modul

Installation

CentOS/RHEL/RockyLinux/etc. und Amazon Linux werden unterstützt und erfordern ein Abonnement.

Fedora Linux wird kostenlos unterstützt und benötigt kein Abonnement.

OS-spezifische vollständige Installations- und Konfigurationsanleitungen verfügbar:

Weitere unterstützte Betriebssysteme

dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-captcha

Aktivieren Sie das Modul, indem Sie Folgendes an den Anfang von /etc/nginx/nginx.conf hinzufügen:

load_module modules/ngx_http_captcha_module.so;

Dieses Dokument beschreibt nginx-module-captcha v0.0.1 veröffentlicht am 14. April 2023.


Beispielkonfiguration:

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) {
        # captcha ungültiger Code
    }
}

Direktiven:

Syntax:  captcha;
Standard: ——
Kontext: location

Aktiviert die Generierung des Captcha-Bildes.


Syntax:  captcha_case on | off;
Standard: aus
Kontext: http, server, location

Aktiviert/deaktiviert die Berücksichtigung der Groß-/Kleinschreibung im Captcha.


Syntax:  captcha_expire seconds;
Standard: 3600
Kontext: http, server, location

Legt die Sekunden fest, bevor das Captcha abläuft.


Syntax:  captcha_height pixels;
Standard: 30
Kontext: http, server, location

Legt die Höhe des Captcha-Bildes fest.


Syntax:  captcha_length characters;
Standard: 4
Kontext: http, server, location

Legt die Länge des Captcha-Texts fest.


Syntax:  captcha_size pixels;
Standard: 20
Kontext: http, server, location

Legt die Größe der Captcha-Schriftart fest.


Syntax:  captcha_width pixels;
Standard: 130
Kontext: http, server, location

Legt die Breite des Captcha-Bildes fest.


Syntax:  captcha_charset string;
Standard: abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789
Kontext: http, server, location

Legt die Zeichen fest, die im Captcha-Text verwendet werden.


Syntax:  captcha_csrf string;
Standard: csrf
Kontext: http, server, location

Legt den Namen der CSRF-Variable des Captchas fest.


Syntax:  captcha_font string;
Standard: /usr/share/fonts/ttf-liberation/LiberationSans-Regular.ttf
Kontext: http, server, location

Legt die Schriftart des Captcha-Texts fest.


Syntax:  captcha_name string;
Standard: Captcha
Kontext: http, server, location

Legt den Namen des Captcha-Cookies fest.


Syntax:  captcha_secret string;
Standard: secret
Kontext: http, server, location

Legt das Geheimnis des Captchas fest.

GitHub

Sie finden zusätzliche Konfigurationstipps und Dokumentationen für dieses Modul im GitHub Repository für nginx-module-captcha.