Nginx服务器加固配置Naxsi软件提升WEB应用安全防火墙WAF设置

今天下午和群里网友聊天,有聊到服务器的运维他们采用的是安装Naxsi软件进行WEB应用安全防御WAF的。在这里,老蒋也简单的记录基于Nginx引擎中安装Naxsi软件加固WEB的设置。如果我们也有需要的可以在测试环境,不要直接用到生产环境。

Nginx服务器加固配置Naxsi软件提升WEB应用安全防火墙WAF设置

第一、下载Naxsi安全规则组

cd /data/software/
wget https://github.com/nbs-system/naxsi/archive/master.zip
mv master naxsi-master.zip
unzip naxsi-master.zip

第二、重新编译Nginx

cd ngx_openresty-1.4.3.6
./configure --user=www --group=www --prefix=/usr/local/openresty --with-luajit --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_realip_module --add-module=/data/software/naxsi-master/naxsi_src/
gmake
gmake install
cd ../

第三、拷贝规则库

cp /data0/software/naxsi-master/naxsi_config/naxsi_core.rules /usr/local/webserver/nginx/conf/

定义安全规则:

vi /usr/local/webserver/nginx/conf/mysite.rules

添加规则:

vi /usr/local/webserver/nginx/conf/nginx.conf

添加进来

include       /usr/local/webserver/nginx/conf/naxsi_core.rules;

加入到HTTP规则中。

最后,重启Nginx生效

killall -9 nginx
/usr/local/webserver/nginx/sbin/nginx

我们可以测试看看是否生效。

本文出处:老蒋部落 » Nginx服务器加固配置Naxsi软件提升WEB应用安全防火墙WAF设置 | 欢迎分享( 公众号:老蒋朋友圈 )

公众号 「老蒋朋友圈」获取站长新知 / 加QQ群 【1012423279】获取商家优惠推送