1. Install ModSecurity on your server.
- Install the dependencies. Open the Terminal Window and enter :
sudo apt-get install libxml2 libxml2-dev libxml2-utils
sudo apt-get install libaprutil1 libaprutil1-dev
- 64bit users please note – Because of this bug you need to create a symbolic link to libxml2.so.2 or the installation will report the file missing and fail.
ln -s /usr/lib/x86_64-linux-gnu/libxml2.so.2 /usr/lib/libxml2.so.2
sudo apt-get install libapache-mod-security
2. Configure ModSecurity rules.
sudo mv /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf
- The default folder for ModSecurity rules is /etc/modsecurity/ . All .conf files will be included and need to be configured as required.
- We need to activate all the base rules and make sure they also get loaded.
- You might want to edit the SecRequestBodyLimit option in the modsecurity.conf file.
- SecRequestBodyLimit limits the page request size and limits file uploads to 128 KB by default. Change this to the size of files you would accept uploaded to the server.
- This settings is very important as it limits the size of all files that can be uploaded to the server. For CMS sites using Drupal or WordPress this setting is the source of much pain.
- Open the Terminal Window and enter :
sudo vi /etc/modsecurity/modsecurity.conf
- First activate the rules by editing the SecRuleEngine option and set to On.
- Edit the following to option to increase the request limit to 16 MB and save the file :