load_module
The `load_module` directive dynamically loads an NGINX module at runtime.
Description
The load_module directive allows users to load a specified NGINX module dynamically without recompiling the entire NGINX binary. This directive must be placed in the main configuration context and takes one argument: the path to the shared object file (usually with a .so suffix) of the module to be loaded. When the NGINX worker process starts, this directive instructs NGINX to attempt loading the module specified in its argument, allowing for extra functionality to be incorporated into the server without needing to restart or recompile.
This directive can be critical for enabling optional features or third-party modules that expand on core NGINX capabilities, such as additional authentication mechanisms or improved performance enhancements. If the module has dependencies on other modules or shared libraries, those must also be satisfied at runtime for the loading to succeed. Users should ensure that the specified module file is accessible and that the NGINX process has the necessary permissions to load it. If the module fails to load, NGINX will emit an error and may refuse to start, depending on the severity of the error encountered.
To use this directive effectively, users typically define it within the NGINX main configuration block, which is processed before any other configuration settings. It is important to note that any dependencies for the module should be resolved beforehand to avoid runtime errors.
Config Example
load_module modules/ngx_http_custom_module.so;
Ensure the specified module file exists and is accessible to the NGINX process.
Check for dependency issues with other required modules or libraries.
Remember to include this directive only in the main context of the NGINX configuration.