nginx增加modsecurity模块

modsecurity原本是Apache上的一款开源waf,可以有效的增强web安全性,目前已经支持nginx和IIS,配合nginx的灵活和高效,可以打造成生产级的WAF,是保护和审核web安全的利器。

1
2
3
4
5
6
7
8
9
10
11
git clone https://github.com/SpiderLabs/ModSecurity.git
cd ModSecurity/
./autogen.sh
./configure--enable-standalone-module --disable-mlogc
make
cd tengine/
./configure--prefix=/usr/local/nginx
 --conf-path=/etc/nginx/nginx.conf--pid-path=/var/run/nginx/nginx.pid 
--error-log-path=/var/log/nginx/nginx.log--http-log-path=/var/log/nginx/nginx-http.log--add-module=/root/ngx_devel_kit-0.2.19/--add-module=/root/lua-nginx-module-0.9.13/--add-module=/root/ModSecurity/nginx/modsecurity/
 --with-ld-opt="-Wl,-rpath,$LUAJIT_LIB"
make

  modsecurity倾向于过滤和阻止web危险,之所以强大就在于规则,OWASP提供的规则是于社区志愿者维护的,被称为核心规则CRS(corerules),规则可靠强大,当然也可以自定义规则来满足各种需求。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
git clone https://github.com/SpiderLabs/owasp-modsecurity-crs
cp -R owasp-modsecurity-crs /etc/nginx/
cp
 /etc/nginx/owasp-modsecurity-crs/modsecurity_crs_10_setup.conf.example 
/etc/nginx/owasp-modsecurity-crs/modsecurity_crs_10_setup.conf
cd ModSecurity/
cp modsecurity.conf-recommended /etc/nginx/modsecurity.conf
cp unicode.mapping /etc/nginx
vim modsecurity.conf
SecRuleEngine on
nclude owasp-modsecurity-crs/modsecurity_crs_10_setup.conf
Includeowasp-modsecurity-crs/base_rules/modsecurity_crs_41_sql_injection_attacks.conf
Include owasp-modsecurity-crs/base_rules/modsecurity_crs_41_xss_attacks.conf
Includeowasp-modsecurity-crs/base_rules/modsecurity_crs_40_generic_attacks.conf
Includeowasp-modsecurity-crs/experimental_rules/modsecurity_crs_11_dos_protection.conf
Include owasp-modsecurity-crs/experimental_rules/modsecurity_crs_11_brute_force.conf
Includeowasp-modsecurity-crs/optional_rules/modsecurity_crs_16_session_hijacking.conf

  在需要启用modsecurity的主机的location下面加入下面两行即可:

1
2
ModSecurityEnabled on;  
ModSecurityConfig modsecurity.conf;



参考文章

http://www.52os.net/articles/nginx-use-modsecurity-module-as-waf.html

https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#Installation_for_NGINX

http://drops.wooyun.org/tips/2614

http://drops.wooyun.org/tips/3804

http://drops.wooyun.org/tips/734

http://www.freebuf.com/articles/web/18084.html

http://www.freebuf.com/articles/web/16806.html

#使用有两个WEB安全服务器

modSecurity和Naxsi哪个更适合Nginx搭建WAF

modSecurity和Naxsi哪个更适合Nginx搭建WAF的更多相关文章

  1. 用Nginx搭建CDN服务器方法-开启Nginx缓存与镜像,自建图片服务器

    利用Nginx的proxy_cache搭建缓存服务器一:编译ngx_cache_purge1.Nginx的Proxy_cache是根据Key值md5哈希存储缓存,支持任意的Key,例如你可以根据”域名 ...

  2. 14.Nginx搭建及优化

    Nginx搭建及优化 目录 Nginx搭建及优化 Nginx服务基础 概述 Nginx和Apache的优缺点比较 编译安装Nginx服务 添加Nginx系统服务 Nginx服务配置文件 nginx服务 ...

  3. Nginx搭建反向代理服务器

    [大型网站技术实践]初级篇:借助Nginx搭建反向代理服务器   一.反向代理:Web服务器的“经纪人” 1.1 反向代理初印象 反向代理(Reverse Proxy)方式是指以代理服务器来接受int ...

  4. 搭建rtmp直播流服务之1:使用nginx搭建rtmp直播流服务器(nginx-rtmp模块的安装以及rtmp直播流配置)

    欢迎大家积极开心的加入讨论群 群号:371249677 (点击这里进群) 一.方案简要 首先通过对开发方案的仔细研究(实时监控.流媒体.直播流方案的数据源-->协议转换-->服务器--&g ...

  5. Linux+.NetCore+Nginx搭建集群

    本篇和大家分享的是Linux+NetCore+Nginx搭建负载集群,对于netcore2.0发布后,我一直在看官网的文档并学习,关注有哪些新增的东西,我,一个从1.0到2.0的跟随者这里只总结一句话 ...

  6. 基于nginx搭建简易的基于wcf集群的复杂均衡

    很多情况下基于wcf的复杂均衡都首选zookeeper,这样可以拥有更好的控制粒度,但zk对C# 不大友好,实现起来相对来说比较麻烦,实际情况下,如果 你的负载机制粒度很粗糙的话,优先使用nginx就 ...

  7. Nginx 搭建图片服务器

    Nginx 搭建图片服务器 本章内容通过Nginx 和 FTP 搭建图片服务器.在学习本章内容前,请确保您的Linux 系统已经安装了Nginx和Vsftpd. Nginx 安装:http://www ...

  8. 十大豪门推送sdk,哪个更适合你

    转自:http://jingyan.baidu.com/article/d621e8da0fd7042865913ff5.html 推送,使得开发者可以即时地向其应用程序的用户推送通知或者消息,与用户 ...

  9. Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)

    Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具) 最近因为项目关系,收朋友之托,想制作秀场网站,但是因为之前一直没有涉及到这 ...

随机推荐

  1. 如何快速访问MSDN某一个类或方法的帮助文档

    如何快速访问MSDN某一个类或方法的帮助文档? 我一般都是在Google上搜索的如"string msdn",而不是在Msdn上直接查找(你不可能知道所有的类或方法的完整命名空间) ...

  2. 利用MyEclipse开发一个调用webservice接口的程序

    上一篇文章我们已经学习了如何使用Java 工具MyEclipse开发一个webservice接口,那么接口开发好了如何调用?接下来我们就来解决这个问题. 1:首先随便创建一个Java project选 ...

  3. linux apache服务器优化建议整理(很实用)

    转载:http://www.cnblogs.com/zhongbin/archive/2013/06/11/3131865.html 1.apache服务器的time_wait过多 fin_wait1 ...

  4. 微信小程序 - 自定义模态对话框

    更新日期:2018-11-5 微信bug: 在for循环中使用组件时,遮罩层成黑层. 更新时间 2018-9-30 2018-9-30 1.在电脑上调试input超出输入框范围会出现文字模糊以及位移现 ...

  5. 遇到了一个问题,php数组的

    这两天整一个数据,捯饬了好久... 需求是这样的   <?php $a = array (); $a[] = ['week'=>'1','day'=>'1']; $a[] = ['w ...

  6. 登陆Oracle EBS的Form遇到问题Internet Explorer has modified this page to help prevent cross-site scripting

    登陆Oracle EBS的Form遇到问题Internet Explorer has modified this page to help prevent cross-site scripting 今 ...

  7. 〖Linux〗Debian 7.1.0 Wheezy使用ltib报错的解决办法

    报错内容: scue@Link:/home/work/ltib$ ./ltib Processing platform: Phytec board with the NXP LPC32XX SoC = ...

  8. Pytorch中的norm跟Numpy中的norm对比

  9. proc文件系统分析

    来源: ChinaUnix博客 日期: 2008.01.03 11:46 (共有条评论) 我要评论   二 proc文件系统分析  根据前面的分析,我们可以基本确定对proc文件系统的分析步骤.我将按 ...

  10. 腾讯QQ的发展与未来

    http://wenku.baidu.com/view/15166ddfc1c708a1284a447d.html 腾讯QQ的发展与未来