NGINX load_module 错误 - 如何从包含文件加载模块?

zer*_*314 2 nginx

我已经定义了 nginx 服务器的设置

load_module /etc/nginx/modules-enabled/50-mod-http-image-filter.conf;
include load_modules.include;

# the upstream component nginx needs to connect to
http { upstream educa {
    server      unix:///tmp/educa.sock;
}


server {
    listen       80;
    server_name  www.educaproject.com educaproject.com;
    access_log   off;
    error_log    /home/anton/Course-system/educa/config/logs/nginx_error.log;
    location / {
        include      /etc/nginx/uwsgi_params;
        uwsgi_pass   educa;
    }
}}
Run Code Online (Sandbox Code Playgroud)

但是,使用该命令,我收到错误
'sudo nginx nginx: [emerg] dlopen() "/etc/nginx/modules-enabled/50-mod-http-image-filter.conf" failed (/etc/nginx/modules -enabled/50-mod-http-image-filter.conf:文件太短)在 /home/anton/Course-system/educa/config/nginx.conf:1

load_50-mod-http-image-filter.conf文件的文本为“modulemodules/ngx_http_image_filter_module.so”;

Tim*_*ark 6

您必须load_module在 nginx.conf 中定义所有指令,或者使用将被包含并包含load_module您想要的指令的包含文件。该load_module指令仅允许在主配置上下文中使用。确保所有load_module语句都在那里定义:

user  nginx;                                                  
worker_processes  auto;                                       
                                                              
error_log  /var/log/nginx/error.log warn;                     
pid        /var/run/nginx.pid;                                
                                                              

include /etc/nginx/modules-enabled/50-mod-http-image-filter.conf;
                                                              
events {                                                      
    worker_connections  1024;                                 
}                                                             
                                                              
                                                              
http {   
....
}
                                                 
Run Code Online (Sandbox Code Playgroud)

专业提示:我将所有特殊包含命名为非 *.conf,因为这使我可以更好地控制如何以及在何处包含它们。我仍然可以在我的区块中使用类似include *.conf稍后的东西http,而不会破坏任何东西。