# ![CrowdSec](<https://daemonless.io/images/logos/crowdsec.svg>) CrowdSec

[![Build Status](<https://img.shields.io/github/actions/workflow/status/daemonless/crowdsec/build.yaml?style=flat-square&amp;label=Build&amp;color=green>)](<https://github.com/daemonless/crowdsec/actions>) [![Last Commit](<https://img.shields.io/github/last-commit/daemonless/crowdsec?style=flat-square&amp;label=Last+Commit&amp;color=blue>)](<https://github.com/daemonless/crowdsec/commits>) [![OCI Pulls](<https://img.shields.io/docker/pulls/daemonless/crowdsec?style=flat-square&amp;label=OCI+Pulls&amp;color=blue>)](<https://hub.docker.com/r/daemonless/crowdsec>)

Open-source collaborative intrusion detection and prevention engine (IDS/IPS and AppSec WAF) with crowdsourced threat intelligence.

- [![CrowdSec screenshot 1](<https://daemonless.io/images/screenshots/crowdsec/console-overview.png>)](</images/screenshots/crowdsec/console-overview.png>)
- [![CrowdSec screenshot 2](<https://daemonless.io/images/screenshots/crowdsec/data_insights.png>)](</images/screenshots/crowdsec/data_insights.png>)
- [![CrowdSec screenshot 3](<https://daemonless.io/images/screenshots/crowdsec/overview-full-dark.png>)](</images/screenshots/crowdsec/overview-full-dark.png>)

|  |  |
| --- | --- |
| **Port** | `8080` |
| **Registry** | [`ghcr.io/daemonless/crowdsec`](<https://github.com/daemonless/crowdsec/pkgs/container/crowdsec>) |
| **Daemonless** | [daemonless/crowdsec](<https://github.com/daemonless/crowdsec>) |
| **Source** | [crowdsecurity/crowdsec](<https://github.com/crowdsecurity/crowdsec>) |
| **Website** | [www.crowdsec.net](<https://www.crowdsec.net/>) |

## Storage layout and CLI

Configuration files (`/config/etc`) and the SQLite database plus downloaded Hub data (`/config/data`) are persisted under `/config`. Inside the container, `/usr/local/etc/crowdsec`, `/etc/crowdsec`, and `/var/db/crowdsec/data` symlink into `/config`, so standard `cscli` commands work without extra flags:

```
podman exec crowdsec cscli metrics
podman exec crowdsec cscli decisions list
```

## Log acquisition and collections

Mount target service logs read-only into the container, add acquisition definitions under `/config/etc/acquis.d/*.yaml` (or edit `/config/etc/acquis.yaml`), and list matching Hub collections in `COLLECTIONS` (for example `crowdsecurity/nginx`, `crowdsecurity/caddy`, or `crowdsecurity/haproxy`). For logs from another host or router (such as OpenWRT or HAProxy), add a `source: syslog` listener under `/config/etc/acquis.d/` with a `listen_port` above 1024 (the container does not run as root) and publish that UDP port.

## Bouncers and firewall remediation

On FreeBSD or a router, a firewall bouncer (`security/crowdsec-firewall-bouncer`, OPNsense plugin, or OpenWRT firewall bouncer) connects to this container's LAPI on port `8080`. Reverse-proxy and application bouncers (Caddy, nginx, HAProxy, Cloudflare) connect to port `8080` the same way.

Register bouncers with `cscli bouncers add <name>` or pass `BOUNCER_KEY_<name>=<api-key>` (or `BOUNCER_KEY_<name>_FILE=/path/to/key`) to auto-register on startup.

## Optional ports

Publish `6060` for Prometheus `/metrics` or `7422` when enabling an AppSec WAF listener in `/config/etc/acquis.d/`.

## Prerequisites

Before deploying, ensure your host environment is ready. See the [Quick Start Guide](<https://daemonless.io/guides/quick-start/index.md>) for host setup instructions, including the security model for host vs. container privileges.

## Deployment

**Customize Paths, UID & Ports**

Install and manage **CrowdSec** on FreeBSD with [fjord](<https://fjord.daemonless.io>):

```
fjord install crowdsec
```

Or open the **App Store** in the fjord web UI and install **CrowdSec** from the wizard. New to fjord? See the [Install Guide](<https://fjord.daemonless.io/install/>).

```
services:
  crowdsec:
    image: "ghcr.io/daemonless/crowdsec:latest"
    container_name: crowdsec
    environment:
      - PUID=1000  # User ID for the application process
      - PGID=1000  # Group ID for the application process
      - TZ=UTC  # Timezone for the container
      # - COLLECTIONS=  # Space-separated CrowdSec Hub collections to install on startup (for example crowdsecurity/caddy crowdsecurity/nginx)
      # - PARSERS=  # Space-separated CrowdSec Hub parsers to install on startup
      # - SCENARIOS=  # Space-separated CrowdSec Hub scenarios to install on startup
      # - ENROLL_KEY=  # CrowdSec Console enrollment key
      # - ENROLL_INSTANCE_NAME=  # Instance name registered in CrowdSec Console when ENROLL_KEY is set
      # - ENROLL_TAGS=  # Space-separated tags passed to cscli console enroll
      # - POSTOVERFLOWS=  # Space-separated CrowdSec Hub postoverflows to install on startup
      # - APPSEC_CONFIGS=  # Space-separated CrowdSec AppSec WAF configs to install on startup
      # - APPSEC_RULES=  # Space-separated CrowdSec AppSec WAF rules to install on startup
      # - DISABLE_ONLINE_API=  # Disable Central API (CAPI) registration and community blocklist pulls
      # - DISABLE_AGENT=  # Run only the Local API (LAPI) and disable the log processor agent (-no-cs)
      # - NO_HUB_UPGRADE=  # Skip automatic CrowdSec Hub index updates and upgrades on startup
      # - CUSTOM_HOSTNAME=  # Machine name this instance registers with its Local API (default localhost)
      # - LOCAL_API_URL=  # Local API URL written to local_api_credentials.yaml for cscli and the agent (default http://127.0.0.1:8080)
    volumes:
      - "/containers/crowdsec:/config"
    ports:
      - "8080:8080"
    # always (not unless-stopped) so FreeBSD's podman rc.d auto-starts it at boot
    restart: always
```

Save as `compose.yaml`, then run `podman-compose up -d`.

> [!WARNING]
>
> Exposing ports in AppJail means that your service can be reached from remote hosts. If that is not your intention, do not expose the ports and communicate with the service using the jail's IPv4 address or hostname assigned by the virtual network.

```
# .env

DIRECTOR_PROJECT=crowdsec
PUID=1000
PGID=1000
TZ=UTC
```

```
# appjail-director.yml

options:
  - virtualnet: ':<random> default'
  - nat:
services:
  crowdsec:
    name: crowdsec
    options:
      - container: 'args:--pull'
      - expose: '8080:8080 proto:tcp'
    oci:
      user: root
      environment:
        - PUID: !ENV '${PUID}'
        - PGID: !ENV '${PGID}'
        - TZ: !ENV '${TZ}'
    volumes:
      - crowdsec: /config
volumes:
  crowdsec:
    device: '/containers/crowdsec'
```

```
# Makejail

ARG tag=latest

OPTION container=boot
OPTION overwrite=force
OPTION from=ghcr.io/daemonless/crowdsec:${tag}
```

Save the files above, then run `appjail-director up`.

> [!WARNING]
>
> **Experimental**
>
> Bastille's OCI support is experimental. It requires `buildah` and shares the host network stack (`inherit`). Mount volumes with `--volume HOST JAIL`; without it, image-declared volumes are stored under `${bastille_volumesdir}/${jail}`.

```
services:
  crowdsec:
    name: crowdsec
    image: "ghcr.io/daemonless/crowdsec:latest"
    network:
      - mode: host
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=UTC
    volumes:
      - "/containers/crowdsec:/config"
```

Save as `bastille-compose.yml`, then run `bastille up`.

Open `http://<server>:8080` from another machine (the server's own browser can't use a published port).

## Parameters

### Environment Variables

| Variable | Default | Description |
| --- | --- | --- |
| `PUID` | `1000` | User ID for the application process |
| `PGID` | `1000` | Group ID for the application process |
| `TZ` | `UTC` | Timezone for the container |
| `COLLECTIONS` | \`\` | Space-separated CrowdSec Hub collections to install on startup (for example crowdsecurity/caddy crowdsecurity/nginx) |
| `PARSERS` | \`\` | Space-separated CrowdSec Hub parsers to install on startup |
| `SCENARIOS` | \`\` | Space-separated CrowdSec Hub scenarios to install on startup |
| `ENROLL_KEY` | `<ENROLL_KEY>` | CrowdSec Console enrollment key |
| `ENROLL_INSTANCE_NAME` | \`\` | Instance name registered in CrowdSec Console when ENROLL\_KEY is set |
| `ENROLL_TAGS` | \`\` | Space-separated tags passed to cscli console enroll |
| `POSTOVERFLOWS` | \`\` | Space-separated CrowdSec Hub postoverflows to install on startup |
| `APPSEC_CONFIGS` | \`\` | Space-separated CrowdSec AppSec WAF configs to install on startup |
| `APPSEC_RULES` | \`\` | Space-separated CrowdSec AppSec WAF rules to install on startup |
| `DISABLE_ONLINE_API` | \`\` | Disable Central API (CAPI) registration and community blocklist pulls |
| `DISABLE_AGENT` | \`\` | Run only the Local API (LAPI) and disable the log processor agent (-no-cs) |
| `NO_HUB_UPGRADE` | \`\` | Skip automatic CrowdSec Hub index updates and upgrades on startup |
| `CUSTOM_HOSTNAME` | \`\` | Machine name this instance registers with its Local API (default localhost) |
| `LOCAL_API_URL` | \`\` | Local API URL written to local\_api\_credentials.yaml for cscli and the agent (default [http://127.0.0.1:8080](<http://127.0.0.1:8080>)) |

### Volumes

| Path | Description |
| --- | --- |
| `/config` | Persistent configuration (/config/etc) and database/hub data (/config/data) |

### Ports

| Port | Protocol | Description |
| --- | --- | --- |
| `8080` | TCP | Local API (LAPI) |

## Version Tags

Multi-arch manifests — resolve automatically to the right image for your platform.

| Tag | Description | Best For |
| :--- | :--- | :--- |
| `latest` / `pkg` | **FreeBSD Quarterly**. Uses stable, tested packages. | Most users — recommended. |
| `pkg-latest` | **FreeBSD Latest**. Rolling package updates. | Staying current. |

| Tag | Description | Best For |
| :--- | :--- | :--- |
| `latest-amd64` / `pkg-amd64` | **FreeBSD Quarterly**. Uses stable, tested packages. | Most users — recommended. |
| `pkg-latest-amd64` | **FreeBSD Latest**. Rolling package updates. | Staying current. |

| Tag | Description | Best For |
| :--- | :--- | :--- |
| `latest-aarch64` / `pkg-aarch64` | **FreeBSD Quarterly**. Uses stable, tested packages. | Most users — recommended. |
| `pkg-latest-aarch64` | **FreeBSD Latest**. Rolling package updates. | Staying current. |

> [!NOTE]
>
> **Implementation Details**
>
> - **Architectures:** amd64, aarch64
> - **User:** `bsd` (UID/GID set via [PUID/PGID](<https://daemonless.io/guides/permissions/index.md>)). Defaults to `1000:1000`.
> - **Base:** Built on `ghcr.io/daemonless/base` (FreeBSD 15.1).

---

Need help? Join our [Discord](<https://discord.gg/Kb9tkhecZT>) community.
