testcookie_refresh_template

Sets a custom template for the testcookie challenge/response mechanism in NGINX.

Syntaxtestcookie_refresh_template path;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The testcookie_refresh_template directive defines a custom template used during the generation of challenge cookies for client requests by the NGINX testcookie robot mitigation module. This directive allows for the flexibility to customize the HTML or JavaScript that is presented to clients as part of the cookie verification process. By using a template, administrators can provide a tailored user experience during the cookie setting phase, enhancing security through personalized interfaces while also ensuring that the challenge is both visually coherent and functional.

The primary argument for this directive is a string that represents the path to the custom template file. This file may contain HTML and JavaScript that instructs the user's browser on how to handle and send the challenge cookie back to the server. If this directive is not specified, the module will fall back to its default behavior, which typically includes a standard cookie-setting mechanism that may not account for custom branding or tailored user experiences. It is essential to ensure that the template adheres to the expected JavaScript behaviors required for proper cookie handling and response validation.

The testcookie_refresh_template should be defined in http, server, or location contexts, depending on the desired level of specificity for the cookie challenge application. Use cases include different templates for various location blocks or server configurations to refine the user experience depending on their access point or IP origin.

Config Example

location /path {
    testcookie_refresh_template "/path/to/custom/template.html";
}

Ensure that the template file path is correct and accessible by the NGINX worker process.

Custom templates must be validated for proper JavaScript execution; any errors can cause challenges to fail silently.

Make sure to escape characters in HTML correctly to avoid breaking the template's structure.

← Back to all directives