๐Ÿ›ก๏ธ 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


ย  ย 
๐Ÿ“ฆ 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

  1. Open the MOS Hub and search for CrowdSec
  2. Keep default collections or customize for your services
  3. Click Install
  4. CrowdSec will auto-install the configured collections

Get your enrollment key:

  1. Create account at app.crowdsec.net
  2. Go to Instances โ†’ Add Instance
  3. Copy the enrollment key
  4. Set it as ENROLL_KEY in the container environment
  5. 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

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

  1. Use multiple detection sources - Install collections for all your services
  2. Configure appropriate bouncers - Block at the right level (firewall, nginx, etc.)
  3. Monitor false positives - Check alerts regularly with cscli alerts list
  4. Whitelist your IPs - Add your own IPs to prevent accidental lockout:
    docker exec crowdsec cscli decisions add --ip YOUR_IP --type whitelist
    
  5. 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 crowdsec to watch detections in real-time during initial setup.

๐Ÿ“š For more information: Visit the CrowdSec documentation for bouncer setup, custom scenarios, and API reference.


MOS Templates โ€“ maintained by J000K3R

This site uses Just the Docs, a documentation theme for Jekyll.