Does CloudPanel Support ModSecurity? How to Enable It?

Nemesis

Active member
Joined
Mar 22, 2025
Messages
35
Points
61
Age
26
Does CloudPanel come with ModSecurity support out of the box? If not, how can I install and enable ModSecurity on a server running CloudPanel?
 
Solution
CloudPanel does not include ModSecurity by default, as it’s designed to be lightweight and performance-focused. However, if you need Web Application Firewall (WAF) capabilities like ModSecurity, you can install and configure it manually.

🔸 What is ModSecurity?​

ModSecurity is an open-source WAF (Web Application Firewall) that protects your applications from common threats like:
  • SQL injection
  • Cross-site scripting (XSS)
  • Path traversal
  • And many more

🔸 Can You Use ModSecurity with CloudPanel?​


Yes — but it requires manual setup. CloudPanel uses Nginx (not Apache), so you’ll need to install ModSecurity as an Nginx module or use ModSecurity v3 (libmodsecurity)...
CloudPanel does not include ModSecurity by default, as it’s designed to be lightweight and performance-focused. However, if you need Web Application Firewall (WAF) capabilities like ModSecurity, you can install and configure it manually.

🔸 What is ModSecurity?​

ModSecurity is an open-source WAF (Web Application Firewall) that protects your applications from common threats like:
  • SQL injection
  • Cross-site scripting (XSS)
  • Path traversal
  • And many more

🔸 Can You Use ModSecurity with CloudPanel?​


Yes — but it requires manual setup. CloudPanel uses Nginx (not Apache), so you’ll need to install ModSecurity as an Nginx module or use ModSecurity v3 (libmodsecurity).

🔧 How to Install ModSecurity with Nginx (CloudPanel)


Important: This process requires advanced knowledge of Linux and may require compiling Nginx from source. Not officially supported by CloudPanel.

Step-by-Step:​

  1. Install Dependencies:
  2. Code:
    sudo apt update
    sudo apt install git build-essential libpcre3 libpcre3-dev libssl-dev zlib1g-dev


  3. Install ModSecurity v3:
  4. Code:
    cd /usr/src
    git clone --depth 1 https://github.com/SpiderLabs/ModSecurity
    cd ModSecurity
    git submodule init
    git submodule update
    ./build.sh
    ./configure
    make
    sudo make install


  5. Compile Nginx with ModSecurity module (optional if needed)
    You may need to recompile Nginx with the
    Code:
    --add-module=/path/to/ModSecurity-nginx.
  6. Download OWASP CRS (Rule Set):
  7. Code:
    cd /etc/nginx
    git clone https://github.com/coreruleset/coreruleset.git

  8. Configure ModSecurity in Nginx:Add this inside your server block:
  9. Code:
    modsecurity on;
    modsecurity_rules_file /etc/nginx/modsec/main.conf;

  10. Restart Nginx:
    Code:
    sudo systemctl restart nginx

🛡️ Alternative: Use Cloudflare WAF​


If manual installation feels too complex, a simpler and CloudPanel-friendly alternative is to use Cloudflare’s WAF, which:
  • Integrates easily with CloudPanel
  • Offers DDoS protection and WAF rules
  • Requires no server-side configuration

✅ Summary:​

  • ❌ ModSecurity is not built into CloudPanel
  • ✅ You can install it manually (advanced users)
  • 🔁 Easier option: Use Cloudflare or Sucuri as external WAF solutions
 
Solution
Back
Top