用ModSecurity启动WAF的一次小试
来源:岁月联盟
时间:2020-03-16
yajl-devel /
zlib-devel
获取所有资源
现在所有软件都已安装到位,设置一个可以使用的环境。请注意,因为这是一个测试环境,所以没有sudo使用,一切都以root身份完成。
cd
mkdir owasp
cd owasp
然后下载所有资源。需要GeoIP2,因为GeoIP将很快被弃用,下载后并与NGINX一起安装。
wget https://nginx.org/download/nginx-1.17.8.tar.gz
wget https://github.com/SpiderLabs/ModSecurity/releases/download/v3.0.4/modsecurity-v3.0.4.tar.gz
wget https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.2.0.tar.gz -O CRS_v3.2.0.tar.gz
git clone --recursive https://github.com/maxmind/libmaxminddb
git clone https://github.com/SpiderLabs/ModSecurity
git clone https://github.com/SpiderLabs/ModSecurity-nginx
git clone https://github.com/leev/ngx_http_geoip2_module
MaxMin library
ModSecurity库和ModSecurity模块都需要libmaxmin,因此首先
cd libmaxminddb
./bootstrap
./configure
make
make check
make install
cd ..
配置并安装modsecurity库
而之后libmaxmin的modsecurity库
tar -xvf modsecurity-v3.0.4.tar.gz
cd modsecurity-v3.0.4
./configure --with-lmdb --with-maxmind=/usr/local
make
make install
cd ..
配置并安装modsecurity模块
现在modsecurity库已可用,创建模块
cd ModSecurity
sh build.sh
git submodule init
git submodule update
./configure --with-lmdb --with-maxmind=/usr/local
make
make install
cd ..
棘手的一点
为了使NGINX能够接受并加载模块,必须使用与已安装的NGXINX完全相同的配置选项来编译它们。这些可以通过nginx -V命令确定。
但是不知何故我这里无法正常工作。我尝试了所有可能找到的选项,但一直会遇到binairy不兼容错误。因此,我决定也从头开始编译NGINX。当然,这具有以下缺点:NGINX无法再通过packagemanager进行升级,但是由于模块和nginx二进制文件之间的严格匹配,已经无法实现。我想确保自建nginx内容不会干扰系统的其余部分,因此我将所有内容都放入/usr/local/nginx。首先,我采用了配置选项,利用安装的NGINX,最后得到了:
tar -xvf nginx-1.17.8.tar.gz
cd nginx-1.17.8
./configure /
--prefix=/usr/local/nginx /
--sbin-path=/usr/local/nginx/sbin/nginx /
--modules-path=/usr/local/nginx/modules /
--conf-path=/usr/local/nginx/etc/nginx.conf /
--error-log-path=/var/log/nginx/error.log /
--http-log-path=/var/log/nginx/access.log /
--pid-path=/var/run/nginx.pid /
--lock-path=/var/run/nginx.lock /
--http-client-body-temp-path=/var/cache/nginx/client_temp /
--http-proxy-temp-path=/var/cache/nginx/proxy_temp /
上一页 [1] [2] [3] [4] [5] 下一页
上一篇:避免凭证转储攻击的5个技巧