【问题标题】:Centos7 Nginx mod_security - unknown directive "ModSecurityEnabled"Centos 7 Nginx modsecurity - 未知指令“ModSecurity Enabled”
【发布时间】:2019-02-28 02:25:12
【问题描述】:

通过 yum 安装了 nginx / nginx-module-security / libmodsecurity。

创建于:/usr/lib64/nginx/modules/ngx_http_modsecurity_module.so

nginx.conf:

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

load_module /usr/lib64/nginx/modules/ngx_http_modsecurity_module.so;    

events {

    worker_connections 1024;

}

http {

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/services/*.conf;

}

试试 VHOST:

location / {
            ModSecurityEnabled on;
            ModSecurityConfig /etc/nginx/modsec_includes.conf;
...

服务nginx重启,出错,systemctl状态nginx.service:

nginx: [emerg] unknown directive "ModSecurityEnabled" in {location path}

什么问题以及如何解决?

【问题讨论】:

    标签: nginx module centos mod-security


    【解决方案1】:

    如果您通过this repo 中的yum 安装模块,它会指示您在哪里可以找到文档,例如:

    ----------------------------------------------------------------------
    
    The security dynamic module for nginx has been installed.
    To enable this module, add the following to /etc/nginx/nginx.conf
    and reload nginx:
    
        load_module modules/ngx_http_modsecurity_module.so;
    
    Please refer to the module documentation for further details:
    https://github.com/SpiderLabs/ModSecurity-nginx
    
    ----------------------------------------------------------------------
    

    如果您关注此link,您将了解到新的 Modsecurity 模块与 v2 相比具有不同的配置指令。

    所以:

    server {
        modsecurity on;
        location / {
            root /var/www/html;
            modsecurity_rules_file /etc/my_modsecurity_rules.conf;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-10
      • 1970-01-01
      • 1970-01-01
      • 2018-12-05
      • 2020-02-17
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      相关资源
      最近更新 更多