js_challenge_html

The `js_challenge_html` directive specifies a path to an HTML file used in the JavaScript-based challenge response mechanism for validating clients in NGINX.

Syntaxjs_challenge_html "/path/to/html/file.html";
Defaultnone
Contextserver, location
Arguments1

Description

The js_challenge_html directive is part of the NGINX JavaScript challenge module and is utilized to configure a custom HTML body that will be served to clients when they trigger a JavaScript proof-of-work challenge. This mechanism helps validate the authenticity of incoming requests, acting as a deterrent to automated bots while allowing legitimate users to pass through after successfully executing the JavaScript challenge. The path specified in this directive should point to an HTML file that contains the necessary JavaScript logic for the challenge to function properly.

The js_challenge_html directive takes a single string argument which serves as the file path for the HTML content to be included in the response body. This body is customizable and allows for a tailored user interaction experience. For effective implementation, it's crucial to ensure that the specified file exists and is readable by the NGINX process. If the path is incorrect or the file is not accessible, the default behavior of the challenge will not be altered, possibly leading to undesirable user experience.

This directive can be used within the contexts of a server or location block, allowing for flexibility in applying the JavaScript challenge on a more granular basis. By leveraging this directive, administrators can provide a coherent brand experience even during security checks, enhancing the overall user satisfaction while maintaining robust security measures.

Config Example

server {
    js_challenge on;
    js_challenge_secret "change me!";
    js_challenge_html "/usr/share/nginx/html/challenge_body.html";
    js_challenge_title "Verifying your browser...";
}

Ensure the specified HTML file path is correct and accessible by the NGINX process.

If used in a location context, verify that it does not conflict with other location directives.

Be cautious of caching issues that may cause stale challenges to be presented to users.

← Back to all directives