Skip to main content
Security Engine version:
Version: Next

CrowdSec WAF General Setup

This guide covers the core AppSec Component setup that applies to all web servers and reverse proxies. After completing these steps, configure your remediation component (bouncer) to forward requests to the AppSec Component.

Prerequisitesโ€‹

  • CrowdSec Security Engine (>= 1.5.6) installed and running
  • A compatible remediation component (bouncer) for your web server or reverse proxy

AppSec Component Setupโ€‹

AppSec setup has two steps:

  • Download rules and configuration collections.
  • Configure AppSec as a new acquisition datasource (AppSec datasource).

The following sections will guide you through the default setup.

After installation, verify everything works with the ๐Ÿฉบ Health Check.

Collection Installationโ€‹

Install the essential AppSec collections that provide virtual patching rules and generic attack detection:

SH
sudo cscli collections install crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-generic-rules

These collections include:

  • Virtual Patching Rules: Protection against known vulnerabilities (CVEs)
  • Generic Attack Detection: Common web attack patterns
  • AppSec Configuration: Default AppSec configuration file linking rules together
  • CrowdSec Parsers & Scenarios: For processing AppSec events and creating alerts

Acquisition Configurationโ€‹

Configure CrowdSec to expose the AppSec Component by creating an acquisition file (AppSec datasource).

  1. Create the acquisition directory (if it doesn't exist):
SH
sudo mkdir -p /etc/crowdsec/acquis.d/
  1. Create the AppSec acquisition configuration:
SH
sudo cat > /etc/crowdsec/acquis.d/appsec.yaml << EOF
appsec_configs:
- crowdsecurity/appsec-default
labels:
type: appsec
listen_addr: 127.0.0.1:7422
source: appsec
name: myAppSecComponent
EOF

Configuration explained:

  • appsec_configs: Uses the AppSec configuration(s) from the installed collections
  • listen_addr: IP and port where the AppSec Component listens (default: 127.0.0.1:7422)
  • source: Identifies this as an AppSec data source
  • name: A friendly name for your AppSec component
Security Note

Do not expose the AppSec Component to the internet. It should only be accessible from your web server or reverse proxy.

Start the AppSec Componentโ€‹

Restart CrowdSec to activate the AppSec Component:

SH
sudo systemctl restart crowdsec

Testing WAF Componentโ€‹

Testing Configurationโ€‹

Check that the AppSec Component is running:

SH
sudo netstat -tlpn | grep 7422
Output example
SH
tcp        0      0 127.0.0.1:7422            0.0.0.0:*               LISTEN      12345/crowdsec
note

The output may look differently depending on which command you used but as long as you see the port and the process crowdsec, it means the AppSec Component is running.

Check CrowdSec logs for successful startup:

SH
sudo tail -f /var/log/crowdsec.log

Look for messages like:

TEXT
INFO[...] Starting Appsec server on 127.0.0.1:7422/
INFO[...] Appsec Runner ready to process event

Next stepsโ€‹

Now that the AppSec Component is configured and running, you need to:

  1. Configure your remediation component to forward requests to http://127.0.0.1:7422
  2. Test the setup by triggering a rule
  3. Monitor alerts with sudo cscli alerts list or in the CrowdSec Console

For specific remediation component configuration, see:

Once your remediation component is in place, continue with:

Testing Detectionโ€‹

If you've enabled an WAF-capable bouncer with CrowdSec WAF, you can trigger the crowdsecurity/appsec-generic-test dummy scenario. This scenario does not lead to a decision, but it is a good way to confirm the setup is working.

Trigger the dummy scenario by accessing a probe path on your web server:

1๏ธโƒฃ Access your service URL with this path: /crowdsec-test-NtktlJHV4TfBSK3wvlhiOBnl

SH
curl -I https://<your-service-url>/crowdsec-test-NtktlJHV4TfBSK3wvlhiOBnl

2๏ธโƒฃ Confirm the alert has triggered for crowdsecurity/appsec-generic-test

SH
sudo cscli alerts list | grep crowdsecurity/appsec-generic-test

3๏ธโƒฃ The alert will also appear in the Console alerts

appsec-generic-test console view

info

This scenario can only be triggered again after a 1-minute delay.

Optional: Advanced Configurationโ€‹

Multiple AppSec Configurationsโ€‹

You can load multiple AppSec configurations for different rule sets:

YAML
# /etc/crowdsec/acquis.d/appsec.yaml
appsec_configs:
- crowdsecurity/appsec-default # Virtual patching rules (in-band)
- crowdsecurity/crs # OWASP CRS rules (out-of-band)
labels:
type: appsec
listen_addr: 127.0.0.1:7422
source: appsec
name: myAppSecComponent

Custom Port Configurationโ€‹

To use a different port, update the listen_addr in your acquisition file and ensure your remediation component points to the same address.

Troubleshootingโ€‹

If the AppSec Component fails to start:

  1. Check port availability: Ensure port 7422 isn't already in use
  2. Verify collections: Run sudo cscli collections list to confirm installation
  3. Check configuration syntax: Validate your appsec.yaml file
  4. Review logs: Check /var/log/crowdsec.log for error messages

For detailed troubleshooting, see the AppSec Troubleshooting Guide.

CrowdSec Docs
We use cookies

This site uses cookies to help us improve your experience. You can accept or decline below.