http-captcha #

Server-rendered CAPTCHA image generator — emits a PNG challenge tied to a cookie; pair with a CSRF token and an MD5 check to gate POST endpoints (login, signup, comment forms) against simple bot traffic.

Source: upstream source

Directives

captcha #

syntax: captcha;  ·  default: ——  ·  context: location

Enables generation of captcha image.

captcha_case #

syntax: captcha_case on | off;  ·  default: off  ·  context: http, server, location

Enables/disables ignoring captcha case.

captcha_charset #

syntax: captcha_charset string;  ·  default: abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789  ·  context: http, server, location

Sets characters used in captcha text.

captcha_csrf #

syntax: captcha_csrf string;  ·  default: csrf  ·  context: http, server, location

Sets name of csrf var of captcha.

captcha_expire #

syntax: captcha_expire seconds;  ·  default: 3600  ·  context: http, server, location

Sets seconds before expiring captcha.

captcha_font #

syntax: captcha_font string;  ·  default: /usr/share/fonts/ttf-liberation/LiberationSans-Regular.ttf  ·  context: http, server, location

Sets font of captcha text.

captcha_height #

syntax: captcha_height pixels;  ·  default: 30  ·  context: http, server, location

Sets height of captcha image.

captcha_length #

syntax: captcha_length characters;  ·  default: 4  ·  context: http, server, location

Sets length of captcha text.

captcha_level #

syntax: captcha_level 1 arg (integer);  ·  context: http, server, location

Integer value.

captcha_line #

syntax: captcha_line 1 arg (integer);  ·  context: http, server, location

Integer value.

captcha_name #

syntax: captcha_name string;  ·  default: Captcha  ·  context: http, server, location

Sets name of captcha cookie.

captcha_secret #

syntax: captcha_secret string;  ·  default: secret  ·  context: http, server, location

Sets secret of captcha.

captcha_size #

syntax: captcha_size pixels;  ·  default: 20  ·  context: http, server, location

Sets size of captcha font.

captcha_star #

syntax: captcha_star 1 arg (integer);  ·  context: http, server, location

Integer value.

captcha_width #

syntax: captcha_width pixels;  ·  default: 130  ·  context: http, server, location

Sets width of captcha image.

Example

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 invalid code
    }
}

↑ back to index