captcha_font

The 'captcha_font' directive sets the font file for rendering the text in captcha images.

Syntaxcaptcha_font path;
Default/usr/share/fonts/ttf-liberation/LiberationSans-Regular.ttf
Contexthttp, server, location
Arguments1

Description

The 'captcha_font' directive allows you to specify the font file used to render the text displayed in captcha images generated by the NGINX Captcha Module. This font can be a TrueType font (TTF) or OpenType Font (OTF). The specified font file will be used to dictate how the characters are visually represented, which is crucial for creating unique and less recognizable captcha challenges. The flexibility in font choice can help differentiate your captcha from standard ones that might be easier for bots to read, thereby enhancing security.

When configuring this directive, you need to provide a valid path to a font file that is accessible by the NGINX process. Since the captcha image generation relies on proper font rendering, ensure that the chosen font file exists and is readable; otherwise, NGINX may fail to generate the captcha images correctly. Additionally, this directive should be defined in the context of 'http', 'server', or 'location', providing you with adequate control depending on your application architecture.

Using captcha_font in conjunction with other captcha directives, such as captcha_height, captcha_size, and captcha_charset, can help fine-tune the visual aspects of the captcha to fit your design preferences while maintaining security against automated entries.

Config Example

location =/captcha {
    captcha;
    captcha_font /usr/share/fonts/ttf-liberation/LiberationSans-Regular.ttf;
}

Ensure the font file path is correct and accessible by the NGINX worker processes.

Using a font that is too decorative may negatively impact the readability of the captcha, reducing its effectiveness.

Make sure the font file is supported (TTF or OTF) and correctly installed on the server.

← Back to all directives