名称

OpenWAF 支持源码安装和 Docker 安装

学习、开发、需求变动大、有一定维护能力,建议源码安装
仅使用 OpenWAF 进行防护,建议 Docker 安装

Table of Contents

源码安装

Debian&Ubuntu

  1. 安装OpenWAF依赖
    cd /opt
    apt-get install gcc wget git swig make perl build-essential zlib1g-dev libgeoip-dev libncurses5-dev libreadline-dev -y
    wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
    wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
    wget https://openresty.org/download/openresty-1.13.6.2.tar.gz
    tar -zxvf pcre-8.42.tar.gz
    tar -zxvf openssl-1.1.0h.tar.gz
    tar -zxvf openresty-1.13.6.2.tar.gz
    rm -rf pcre-8.42.tar.gz \
           openssl-1.1.0h.tar.gz \
           openresty-1.13.6.2.tar.gz
PS: 
    1.1 OpenSSL 版本要求

        OpenResty 要求 OpenSSL 最低版本在 1.0.2e 以上,但 apt-get 安装 openssl 并不满足此版本,因此提供解决方法如下:

        方法 1. apt-get 使用 backports 源安装 openssl,如 jessie-backports  
            echo "deb http://mirrors.163.com/debian/ jessie-backports main" >> /etc/apt/sources.list  
            apt-get update  
            apt-get install -t jessie-backports openssl  

        方法 2. 下载 openssl 源代码,如 1.1.0h 版本  
            wget -c http://www.openssl.org/source/openssl-1.1.0h.tar.gz  
            tar -zxvf openssl-1.1.0h.tar.gz
            ./config  
            make && make install  

        若用方法 1 和 方法 2 后, openssl version 命令显示的版本依旧低于 1.0.2e 版本,请求方法 3

        方法 3. 编译 openresty 时指定 openssl 安装目录
            wget -c http://www.openssl.org/source/openssl-1.1.0h.tar.gz
            tar -zxvf openssl-1.1.0h.tar.gz
            编译 openresty 时通过 --with-openssl=/path/to/openssl-xxx/ 指定 openssl 安装路径  

        本示例使用方法 3

    1.2 pcre-jit

        OpenResty 依赖 PCRE ,但通过 apt-get 安装无法开启 pcre-jit,解决方法:  

        方法 1. 源码编译
            wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz  
            tar -zxvf pcre-8.42.tar.gz  
            cd pcre-8.42  
            ./configure --enable-jit  
            make && make install  

        方法 2. 编译 openresty 时指定 pcre 安装目录
            wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz  
            tar -zxvf pcre-8.42.tar.gz  
            编译 openresty 时通过 --with-pcre=/path/to/pcre-xxx/ 指定 pcre 安装路径 

        本示例使用方法 2
  1. 安装 OpenWAF
    cd /opt  
    git clone https://github.com/titansec/OpenWAF.git
    mv /opt/OpenWAF/lib/openresty/ngx_openwaf.conf /etc
    mv /opt/OpenWAF/lib/openresty/configure /opt/openresty-1.13.6.2
    cp -RP /opt/OpenWAF/lib/openresty/* /opt/openresty-1.13.6.2/bundle/
    cd /opt/OpenWAF
    make install
PS:
    2.1 ngx_openwaf.conf
        ngx_openwaf.conf 是 OpenResty 的 [nginx](http://nginx.org/en/docs/) 配置文件

    2.2 configure 
        configure 是 OpenResty 的编译文件
        OpenWAF 修改了此文件,用于编译 OpenWAF 所依赖的第三方模块
  1. 编译 openresty
    cd /opt/openresty-1.13.6.2/  
    ./configure --with-pcre-jit --with-ipv6 \  
                --with-http_stub_status_module \  
                --with-http_ssl_module \  
                --with-http_realip_module \  
                --with-http_sub_module  \  
                --with-http_geoip_module \  
                --with-openssl=/opt/openssl-1.1.0h \ 
                --with-pcre=/opt/pcre-8.42
    make && make install 

CentOS

与 [Debian](#debianubuntu) 安装几乎一致,只需在安装依赖时,将 apt-get 一行命令换成以下命令即可:
    yum install gcc gcc-c++ wget GeoIP-devel git swig make perl perl-ExtUtils-Embed readline-devel zlib-devel -y

Others

其他操作系统安装 OpenWAF,可参考 [OpenResty](https://openresty.org/cn/installation.html) 安装  
再安装 OpenWAF 依赖的 swig 即可  

Docker容器安装

1. pull docker images from repository
   docker pull titansec/openwaf

2. start-up docker 
    docker run -d --name openwaf \
               -p 80:80 -p 443:443 \
               -v /opt/openwaf/conf/ngx_openwaf.conf:/etc/ngx_openwaf.conf \
               -v /opt/openwaf/conf/twaf_access_rule.json:/opt/OpenWAF/conf/twaf_access_rule.json \
               -v /opt/openwaf/log/openwaf_error.log:/var/log/openwaf_error.log \
               titansec/openwaf 
PS:
    1. docker pull titansec/openwaf 
        docker pull titansec/openwaf 获取 jessie 的 OpenWAF 最新版
        docker pull titansec/openwaf:latest 获取 jessie 的 OpenWAF 最新版
        docker pull titansec/openwaf:jessie 获取 jessie 的 OpenWAF 最新版
        docker pull titansec/openwaf:centos 获取 centos 的 OpenWAF 最新版

        获取历史版本:
        docker pull titansec/openwaf:x.x.x-jessie 获取 jessie 的 OpenWAF x.x.x 版
        docker pull titansec/openwaf:x.x.x-centos 获取 centos 的 OpenWAF x.x.x 版

        历史版本列表:https://hub.docker.com/r/titansec/openwaf/tags/

    2. 挂载配置文件和日志
        将配置文件保留在宿主机中,更新 OpenWAF 只需更新 Docker 镜像即可
        2.1 挂载 nginx 配置文件
            如,事先将 ngx_openwaf.conf 放在宿主机 /opt/openwaf/conf/ 目录下,然后启动 docker 容器时添加参数如下:
            -v /opt/openwaf/conf/ngx_openwaf.conf:/etc/ngx_openwaf.conf
        2.2 挂载 twaf_access_rule.json 接入规则配置文件
            如,事先将 twaf_access_rule.json 放在宿主机 /opt/openwaf/conf/ 目录下,然后启动 docker 容器时添加参数如下:
            -v /opt/openwaf/conf/twaf_access_rule.json:/opt/OpenWAF/conf/twaf_access_rule.json
        2.3 挂载 nginx 错误日志
            -v /opt/openwaf/log/openwaf_error.log:/var/log/openwaf_error.log

    3. restart 
        修改宿主机中的配置文件后,执行 docker restart openwaf(容器名称) 即可
  • OpenWAF 使用手册

    NameOpenWAF 第一个全方位开源的Web应用防护系统(WAF),更全面的防护功能,更多样的防护策略 Table of Contents Name Version Synopsis Description Installatio...

    OpenWAF 使用手册
  • 轻松玩转 OpenWAF 之 ELK

    名称ELK 是比较火的开源日志分析系统 本节主要介绍,ELK 的 docker 部署及与 OpenWAF 的结合 Table of Contents ELK简介 安装 Elasticsearch Logstash Kibana O...

    轻松玩转 OpenWAF 之 ELK
  • 深入研究 OpenWAF 之 nginx 配置

    名称此文档将详细描述 OpenWAF 的 nginx 配置文件 /etc/ngx_openwaf.conf 中每一项配置 以及接入规则(access_rule)与 nginx 配置的关联 Table of Contents twaf_...

    深入研究 OpenWAF 之 nginx 配置
  • 轻松玩转 OpenWAF 之入门篇

    名称OpenWAF快速入门,即从安装到上线测试的一个快速体验流程,包括安装,发布应用,查看日志,上线测试 Table of Contents 安装 发布应用 日志 规则 安装请看 OpenWAF 安装文档 发布应用 简介 接入规...

    轻松玩转 OpenWAF 之入门篇
  • elastalert

    前言最近想在 ELK 基础上,临时搭一个告警系统,这里介绍有关 elastalert 的安装及使用。 安装参考官方安装说明: git clone https://github.com/bitsensor/elastalert.git;...

    elastalert
  • ipset

    ipset 安装参考文档(待整理)ipset 官方文档ipset 7.1版本链接使用参考文档 简单的流程可以用这几条命令概括使用 ipset 和 iptables 进行 IP 封禁的流程 ipset create blacklist ...

    ipset
  • 藏独组织“野鸡”的挑衅

    前言2019 年 1 月 12 日,有人以“匿名者”名义通过 YouTube 发布视频,呼吁将于2月13日针对中国部分政府网站进行网络攻击,并于 1 月 16 日在 PastBin 发布 100 个被攻击单位网站列表。 追踪视频明确...

    藏独组织“野鸡”的挑衅
  • 删除非目录文件

    linux 下删除一个目录下所有的隐藏文件和非目录文件 前言在 alpine 基础上编译 OpenWAF,想要达到最简,删除无用文件。 亮点rm -rf `ls -Fa | grep '^\.\w'` -- 删除隐...

    删除非目录文件
  • 在 alpine 上编译 openssl 遇到的问题

    alpine 上编译 openssl (v1.1.1) 遇到 ucontext 报错 前言今天在 alpine 基础上编译 openwaf,编到 openssl 时,报 ucontext 相关错误。 ucontext 报错编译 ope...

    在 alpine 上编译 openssl 遇到的问题
  • 用 hugo 创建自己的博客

    如何用 hugo 搭建自己的博客 前言前两天,hexo 打开了自建博客的道路。今天看到了 hugo,准备研究一下。hugo 是用 go 语言开发的,优势在于编译速度快。如果博客文章达到七八百篇,hexo 可能要几十分钟,但 hugo“...

    用 hugo 创建自己的博客