perl_require
The `perl_require` directive loads a Perl module for use in NGINX configurations.
Description
The perl_require directive allows the user to specify a Perl module to be loaded at runtime in the context of NGINX. This directive is useful when you want to extend NGINX functionality using custom Perl code, enabling scriptable control over various aspects of the request handling pipeline. The argument expected by this directive is the path to the Perl module, which can either be a relative or absolute path. The loading process occurs only once, during the initialization phase of the NGINX server, ensuring that the specified module is available for the rest of the server's lifecycle.
When defining this directive, one must ensure that the specified module is correctly formatted and that any dependencies required by the Perl module are met. Upon failure to load the module, NGINX logs an error and fails to start, so proper testing and validation of the module's path and contents are crucial. Because this directive operates at the http context, it influences the entire server and all configurations nested within this context, allowing centralized management of Perl scripts that may assist in handling requests across multiple locations or server blocks.
Config Example
http {
perl_require /path/to/your/module.pm;
}The path to the Perl module must be valid; otherwise, NGINX will fail to start.
Ensure that necessary Perl modules are installed on the server.
Check NGINX error logs for messages related to module loading issues.