perryk.nginx_modsec3_crs3

Ansible角色用于安装Nginx、编译ModSecurity3以及安装OWASP CRS v3规则集

ModSecurity3是一个强大的开源跨平台Web应用防火墙(WAF)。

之前: https://modsecurity.org/,现由 https://owasp.org/ 拥有。

它与一个称为OWASP CRS的规则集密切相关。请注意,此角色通常指的是CRS3,但现在已经发布了CRS版本4。

之前: https://modsecurity.org/crs/,现在为 https://owasp.org/www-project-modsecurity-core-rule-set/
此外: https://coreruleset.org/https://github.com/coreruleset/coreruleset/

另外,这两个模块都需要与Web服务器配合使用,Apache或Nginx,本角色仅支持Nginx。

https://www.nginx.com

ModSecurity3依赖于一些库和软件包,这些将通过此角色进行安装。

此角色还会安装编译所需的任何编译器和其他构建工具。如果这些工具之前没有安装,将会删除它们。

Nginx的支持主要由jdauphant提供的依赖角色ansible-role-nginx提供。

https://github.com/jdauphant/ansible-role-nginx

默认情况下,此角色将从操作系统提供的仓库中安装Nginx软件包,推荐改为从官方Nginx仓库安装。

可以通过设置以下变量实现:

nginx_official_repo: true

可选地,如果您希望进行地理位置查询,此角色还可以构建GeoIP和/或MaxMind Nginx模块。如果想使用MaxMind,您可能需要从这里获取最新的数据库许可证副本: https://www.maxmind.com/en/geoip-databases

您可以通过以下变量启用这些功能:

nginx_modsec3_crs3_geoip_enabled: false nginx_modsec3_crs3_maxmind_enabled: true

注意:如果存在输出,则此角色将不会重新运行配置和构建步骤,因此如果您更改了所需的选项(如上述不同的模块),可能需要删除Makefile并从objs/文件夹中移除任何.so文件。

要求

在运行调用此角色的剧本之前:

安装requirements.yml中所需的任何Ansible角色。请查看这里

ansible-galaxy install -r requirements.yml

需要特别注意的是,此角色将调用nginx角色中的某些任务,因此确保在与此角色相同的位置安装它,并且名称为"ansible-role-nginx"。

也就是说,在您项目的剧本的requirements.yml文件中(而不是此角色的requirements.yml文件),您需要包含此角色和上面提到的角色,如下所示:

- src: perryk.nginx_modsec3_crs3

- src: https://github.com/jdauphant/ansible-role-nginx
  version: master

角色变量

浏览角色的defaults/main.ymlvars/main.yml文件,查看是否有任何您想要更改或需要在剧本中覆盖的内容。

目前没有设置任何显著的变量。

但是nginx角色中有很多变量,关于这些变量的最佳说明可以在角色的README.md文件中的所有示例中找到。

示例剧本

示例剧本调用此角色,为默认Nginx网站添加和启用ModSecurity。

- hosts: servers

  vars:

    nginx_pkgs:
      - nginx
    nginx_install_epel_repo: false
    nginx_official_repo: true
    nginx_official_repo_mainline: true
    nginx_module_configs:
      - ngx_http_modsecurity_module
      - ngx_http_geoip2_module
    nginx_modules_disable:
      - ngx_http_geoip_module
    nginx_sites:
      default:
       - listen 80
       - server_name _
       - "modsecurity on"
       - "modsecurity_rules_file /etc/nginx/modsec/main.conf"
       - root "/usr/share/nginx/html"
       - index index.html

  roles:
    - perryk.nginx-modsec3-crs3

许可

MIT

作者信息

Perry Kollmorgen - https://github.com/perryk

关于项目

Installs Nginx, Compiles ModSecurity3, and downloads the OWASP CRS ruleset (https://nginx.com, https://owasp.org/, https://coreruleset.org/)

安装
ansible-galaxy install perryk.nginx_modsec3_crs3
许可证
mit
下载
364
拥有者