๐ก๏ธ CrowdSec
![]()
CrowdSec is an open-source, lightweight, and collaborative intrusion detection/prevention system. It analyzes logs, detects malicious behavior, shares threat intelligence with the community, and can block IPs through integration with bouncers.
Unlike traditional firewalls, CrowdSec works by analyzing application logs and using a crowd-sourced threat intelligence network to protect your infrastructure from attacks.
๐ท๏ธ Category: Security
๐ณ Image: crowdsecurity/crowdsec:latest
๐ Links
| ย | ย |
|---|---|
| ๐ฆ Project | github.com/crowdsecurity/crowdsec |
| ๐ Support | GitHub Issues |
| ๐ Docs | docs.crowdsec.net |
| ๐ Hub | app.crowdsec.net |
| ๐ Console | app.crowdsec.net |
๐ Ports
| Port | Protocol | Description |
|---|---|---|
8080 | TCP | CrowdSec Local API (LAPI) for bouncers to query decisions |
๐พ Volumes
| Host Path | Container Path | Mode | Description |
|---|---|---|---|
/mnt/cache/appdata/crowdsec/config | /etc/crowdsec | RW | Configuration, parsers, scenarios, collections |
/mnt/cache/appdata/crowdsec/data | /var/lib/crowdsec/data | RW | Database, local API decisions, CLI data |
/var/log | /var/log | RO | Host system logs for analysis |
โ๏ธ Environment Variables
๐ฆ Collections & Hub
| Variable | Default | Masked | Description |
|---|---|---|---|
COLLECTIONS | crowdsecurity/linux crowdsecurity/nginx crowdsecurity/sshd | โ | Collections to auto-install (space-separated) |
ENROLL_KEY | `` | โ | Enrollment key from CrowdSec Console |
ENROLL_INSTANCE_NAME | mos-server | โ | Instance name shown in Console |
๐ง Agent/LAPI Mode
| Variable | Default | Masked | Description |
|---|---|---|---|
DISABLE_AGENT | false | โ | Disable log parser (only LAPI mode) |
DISABLE_API | false | โ | Disable LAPI (only agent mode, connects to remote) |
LEVEL_INFO | false | โ | Enable verbose logging |
๐ค Permissions
| Variable | Default | Masked | Description |
|---|---|---|---|
PUID | 500 | โ | User ID for file permissions |
PGID | 500 | โ | Group ID for file permissions |
TZ | Europe/Vienna | โ | Timezone |
๐ Quick Start
Step 1: Install via MOS Hub
- Open the MOS Hub and search for CrowdSec
- Keep default collections or customize for your services
- Click Install
- CrowdSec will auto-install the configured collections
Step 2: Register with CrowdSec Console (Optional but Recommended)
Get your enrollment key:
- Create account at app.crowdsec.net
- Go to Instances โ Add Instance
- Copy the enrollment key
- Set it as
ENROLL_KEYin the container environment - Restart the container
Step 3: Install Bouncers
CrowdSec detects threats but doesnโt block them alone. You need a bouncer:
| Bouncer | Use Case | Install |
|---|---|---|
| Firewall Bouncer | Block at iptables/nftables level | Run on host |
| Nginx Bouncer | Block in Nginx reverse proxy | Install in nginx container |
| Cloudflare Bouncer | Block at CDN level | Run as separate container |
| Docker Bouncer | Block Docker containers | Run as separate container |
Example: Install Nginx Bouncer for Nginx Proxy Manager:
docker exec crowdsec cscli bouncers add nginx-bouncer
๐ง Common Commands
Check CrowdSec Status
docker exec -it crowdsec cscli metrics
List Installed Collections
docker exec -it crowdsec cscli collections list
Install Additional Collections
# For Docker log parsing
docker exec -it crowdsec cscli collections install crowdsecurity/docker
# For specific services
docker exec -it crowdsec cscli collections install crowdsecurity/nextcloud
docker exec -it crowdsec cscli collections install crowdsecurity/pgsql
View Alerts & Decisions
# Recent alerts
docker exec -it crowdsec cscli alerts list
# Current ban decisions
docker exec -it crowdsec cscli decisions list
# Ban an IP manually
docker exec -it crowdsec cscli decisions add --ip 192.168.1.100 --duration 4h --reason "Manual ban"
# Unban an IP
docker exec -it crowdsec cscli decisions delete --ip 192.168.1.100
Monitor Logs
docker logs -f crowdsec
๐ Popular Collections
| Collection | Description |
|---|---|
crowdsecurity/linux | System log parsing (syslog, auth) |
crowdsecurity/nginx | Nginx access/error log parsing |
crowdsecurity/apache2 | Apache log parsing |
crowdsecurity/sshd | SSH brute force detection |
crowdsecurity/nextcloud | Nextcloud security events |
crowdsecurity/wordpress | WordPress attack detection |
crowdsecurity/docker | Docker daemon log parsing |
๐ Integration Architecture
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Services โโโโโโถโ CrowdSec โโโโโโถโ Bouncers โ
โ (nginx, ssh) โ โ (detects) โ โ (blocks) โ
โ โ โ โ โ โ
โ Logs โโโโโโโโโถโ โ LAPI โโโโโโโโโถโ โ Firewall/Nginxโ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ CrowdSec โ
โ Console/Hub โ
โ (threat intel) โ
โโโโโโโโโโโโโโโโโโโ
๐ CrowdSec Console Features
When enrolled, you get:
- Centralized Dashboard - View alerts from all instances
- Threat Intelligence - See IPs blocked globally
- Blocklists - Subscribe to community blocklists
- Metrics - Visualize attacks and mitigations
๐ Security Best Practices
- Use multiple detection sources - Install collections for all your services
- Configure appropriate bouncers - Block at the right level (firewall, nginx, etc.)
- Monitor false positives - Check alerts regularly with
cscli alerts list - Whitelist your IPs - Add your own IPs to prevent accidental lockout:
docker exec crowdsec cscli decisions add --ip YOUR_IP --type whitelist - Enable enrollment - Join the community for better threat intelligence
โ ๏ธ Note: CrowdSec alone doesnโt block anything. You must install at least one bouncer to enforce decisions!
๐ก Tip: Start with the Nginx Bouncer if using Nginx Proxy Manager - itโs the easiest integration for web applications.
๐ก Tip: Use
docker logs -f crowdsecto watch detections in real-time during initial setup.
๐ For more information: Visit the CrowdSec documentation for bouncer setup, custom scenarios, and API reference.