0x01 关于naxsi
同为开源waf,但跟Modsecurity的不同是,它对nginx的兼容性非常好,而且不依赖现有规则库其实,我们心里都很清楚,单单基于规则库的拦截可能需要经常更新,且容易被绕过,防御起来比较被动
,naxsi安装定制都非常简单方便,占用系统资源相对较少,对实际业务的适用性更强[方便的白名单设置],有一定的学习能力,不过,实际测试中貌似暂时只能拦截从get或者post过来的数据,这也是个小遗憾
0x02 依然是拿之前编译好的lnmp环境[具体如何编译配置,请参考博客相关文章]来做演示,我这里先把之前的配置文件备份下,等会儿好直接拿过来用
1
| php5.5.38 + mysql-5.5.32 + nginx-1.12.1 + centOS6.8_x64
|
1 2 3 4 5
| # netstat -tulnp | grep "80" # pkill nginx # cp /usr/local/nginx/conf/nginx.conf ./ # cp /usr/local/nginx/conf/extra/bwapp.conf ./ # rm -rf /usr/local/nginx*
|
0x03 下载naxsi,重新编译安装nginx,主要是要把naxsi模块加载进去,这里的nginx直接用的最新版的稳定版本
1 2 3 4 5 6 7 8 9 10 11
| # git clone https://github.com/nbs-system/naxsi.git # wget http://nginx.org/download/nginx-1.12.1.tar.gz # yum install pcre pcre-devel openssl openssl-devel -y # useradd -s /sbin/nologin -M nginx # tar xf nginx-1.12.1.tar.gz # cd nginx-1.12.1 # ./configure --prefix=/usr/local/nginx-1.12.1 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-file-aio --with-http_dav_module --add-module=../naxsi/naxsi_src/ # make && make install # ln -s /usr/local/nginx-1.12.1/ /usr/local/nginx # cd /usr/local/nginx/conf/ # mv nginx.conf nginx.conf.bak && egrep -v "^$|#" nginx.conf.bak >> nginx.conf
|