captcha_line

The `captcha_line` directive enables the generation of a captcha image with a specified number of lines.

Syntaxcaptcha_line number;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The captcha_line directive is part of the NGINX Captcha Module and is used to configure the generation of a captcha image that contains a specified number of lines. Captchas are commonly used to prevent automated access to web applications by requiring users to solve a challenge. The directive can be defined in the http, server, or location contexts, allowing for flexible configuration based on application needs.

When using captcha_line, this directive accepts a single integer argument, which represents the number of lines to be drawn in the captcha image. These lines help obscure the characters of the captcha, making it difficult for bots to read while allowing human users to decipher it. The lines may be curved or straight and can vary in thickness and opacity based on other directives such as captcha_width, captcha_height, and captcha_size. Adjusting these configurations properly can enhance the user experience and maintain the security of the captcha mechanism.

Upon activating the captcha_line directive, it works in conjunction with other captcha settings such as captcha_length (which specifies the number of characters in the captcha) and captcha_charset (which defines the set of characters to be used). Together, these directives ensure that the captcha is both visually appealing and challenging for automated systems while remaining legible for human users.

Config Example

location =/captcha {
    captcha;
    captcha_line 3;
}

location =/login {
    set_form_input $captcha_form captcha;
    if ($captcha_form != valid_captcha) {
        # Handle captcha invalid code
    }
}

Ensure that the specified number of lines does not render the captcha unreadable for human users.

Remember to adjust other related captcha configurations such as size and height for visual clarity.

Test various line styles and placements to find a balance between usability and security.

← Back to all directives