How to install Mod_Security on Nginx
来源:互联网 发布:精通shell编程 知乎 编辑:程序博客网 时间:2024/05/22 08:07
ModSecurity for Nginx has been available for a while and we can use it freely in our Nginx webserver. ModSecurity was originally deveoped for Apache webserver, but it’s not available to be integrated with Nginx server, even it is in Beta state it works perfectly in our test enviroment. So, let’s see how to install mod_security on Nginx
Let’s start:
Install required dependencies from Github
CentOS/Fedora/RHEL users:
yum install -y gcc make automake autoconf libtool
yum install -y pcre pcre-devel libxml2 libxml2-devel curl curl-devel httpd-devel
Debian/Ubuntu users:
sudo apt-get install libxml2 libxml2-dev libxml2-utils libaprutil1 libaprutil1-dev
Download, compile and install mod_security
git clone https://github.com/SpiderLabs/ModSecurity.git mod_securitycd mod_security./autogen.sh./configure --enable-standalone-modulemake
Compile Nginx from source with modsecurity
wget http://www.nginx.org/download/nginx-1.4.2.tar.gztar -xvpzf nginx-1.4.2.tar.gzcd nginx-1.4.2./configure --add-module=../mod_security/nginx/modsecuritymakemake install
Nginx ModSecurity Configuration
The ModSecurity configuration file must be definded at nginx.conf file, for example:
server {listen 80;server_name localhost;location / {ModSecurityEnabled on;ModSecurityConfig modsecurity.conf;}}
If you need to have custom rules for your mod_security applied to different directories in your website, you can create new mod_security.conf files, for example:
location /secured { ModSecurityConfig modsecurity3.conf; proxy_pass http://secured.mysite.com/; proxy_read_timeout 180s; }
Or you can even turn off mod_security for one directory in particular:
location /unsecured/ { ModSecurityEnabled off; proxy_pass http://unsecured.mysite.com/; proxy_read_timeout 180s; }
Restart Nginx to apply the changes:
service nginx restart
Popular search terms:
- modsecurity nginx
- nginx mod_security
- mod_security nginx
- mod_security nginx debian
SecDefaultAction "deny,phase:2,status:403"
- How to install Mod_Security on Nginx
- How To Install Wordpress with nginx on Ubuntu 12.04
- how-to-install-nginx-on-centos6.6-x86_64
- How To Install nginx on CentOS 6 with yum
- How to install and configure NGINX on CentOS 7
- How To Install nginx on CentOS 6 with yum
- How To Install WordPress with nginx on Ubuntu 14.04
- install mod_security
- How to Install Nginx, PHP, PHP Extensions, MySQL, and Zend Optimizer on FreeBSD 7
- 二:2.How To Install nginx on CentOS 6 with yum
- How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 12.04
- How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6
- How To Install Linux, Nginx, MySQL, PHP (LEMP) Stack on Debian 7
- How to Install HTTP Git Server With Nginx on Ubuntu 16.04
- How to Install Sun Java on Debian
- How to Install JPCap on Linux
- How to build & install ace on cygwin?
- How to Install Fonts on Ubuntu
- Appium Python API 中文版 By-HZJ
- Android 锁屏显示和屏幕解锁
- 【项目管理】之maven+nexus环境搭建
- HDOJ-1978 How many ways
- 如何开发一个隐藏源代码的library工程。
- How to install Mod_Security on Nginx
- iOS开发之 Objective-C语言基础 :代码块
- Linux命令学习手册-rsync命令
- 【菜鸟学Java】12:代理模式——静态代理怎么玩?
- LeetCode OJ - Remove Duplicates from Sorted Array
- C++面向对象编程<六>:Big Three,三个特殊函数
- 百思不得姐项目学习总结
- mysql 安装 原始密码修改
- HTML 将块设置成圆角