- Lab
- A Cloud Guru
Configure ModSecurity
The goal for this lab is to configure ModSecurity for the Apache web server. There are a few things you need to keep in mind before you start the lab. Take into consideration that firewalld is up and running and that ports 61613, 80, and 65535 are open. Port 61613 is your SSH port where you will connect. Apache is running on port 80, and the back end is functioning on port 65535. SELinux is in enforcing mode. The objective of the lab is to install ModSecurity from the repositories, load it, and instruct Apache to use it. Lastly, install ModSecurity to use OWASP rules in order to apply them against traffic.
Path Info
Table of Contents
-
Challenge
Install `mod_security`
- Install
mod_security
from the repositories:sudo yum install mod_security
- Install
-
Challenge
Configure OWASP Core Rule Set (CRS)
-
Make a
crs
directory:sudo mkdir /etc/httpd/crs
-
Navigate to the new directory:
cd /etc/httpd/crs
-
Install Git:
sudo yum install git
-
Clone a Git repository for OWASP CRS:
sudo git clone https://github.com/SpiderLabs/owasp-modsecurity-crs.git
-
Configure the new repository:
sudo cd /etc/httpd/crs/owasp-modsecurity-crs/
-
Make a copy of
crs-setup.conf.example
and rename it tocrs-setup.conf
:sudo cp crs-setup.conf.example crs-setup.conf
-
-
Challenge
Inform Apache of the Changes
-
Open the configuration file:
sudo vim /etc/httpd/conf/httpd.conf
-
Insert at the bottom of the file:
<IfModule security2_module> Include /etc/httpd/crs/owasp-modsecurity-crs/crs-setup.conf Include /etc/httpd/crs/owasp-modsecurity-crs/rules/*.conf </IfModule>
-
Save and close:
ESC :wq ENTER
-
-
Challenge
Restart Apache and Run a Few Tests to Confirm `mod_security` Is Working Properly
-
Restart the Apache service:
sudo systemctl restart httpd
-
Run a test:
curl -i http://<SERVER_IP_ADDRESS>/index.html -A Nessus
-
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.