CrowdSec remediation (enterprise)#
CrowdSec adds crowd-sourced IP reputation and behavioural detection (brute force, scraping, credential stuffing) to a PosternProxy deployment. It is an external layer: PosternProxy does not bundle or manage it. This guide covers a multi-server, production-oriented setup.
Where CrowdSec fits#
PosternProxy can enable an optional per-host Coraza WAF for HTTP request inspection. CrowdSec stays an external layer and runs alongside it in two parts:
- A detection engine (the CrowdSec agent + Local API, “LAPI”) parses logs and produces time-bounded decisions (bans).
- A bouncer enforces those decisions. The firewall bouncer (nftables/iptables) enforces at the OS layer, independently of Caddy — so it needs no PosternProxy or Caddy configuration change and does not interact with configuration reconciliation.
Because enforcement is at the host, CrowdSec cannot absorb volumetric DDoS or hide your origin — pair it with a CDN edge for public, internet-scale services. Its value is IP-reputation and behavioural blocking, self-hosted.
Reference architecture#
┌────────────────────────────┐
│ Central CrowdSec LAPI │ one engine + hub enrollment
│ (decisions, scenarios) │
└──────────────┬─────────────┘
decisions (API, TLS) │
┌───────────────┬───────┴───────┬───────────────┐
▼ ▼ ▼ ▼
[ Edge node 1 ] [ Edge node 2 ] [ Edge node 3 ] ...
PosternProxy PosternProxy PosternProxy
+ Caddy + Caddy + Caddy
+ firewall + firewall + firewall
bouncer bouncer bouncerEach PosternProxy server (a controller-managed node running Caddy and the
posternproxy-agent) also runs a CrowdSec firewall bouncer that pulls decisions
from a central LAPI. Run the engine/LAPI on dedicated infrastructure, not on an
edge node, so a compromised edge cannot rewrite remediation policy.
Prerequisites#
- A log source CrowdSec can parse. Caddy access logging is off by default in the beta and has no per-host UI, so decide your source: enable a Caddy access log, or parse the system auth log and PosternProxy’s fail2ban activity.
- A network path from each edge to the central LAPI (HTTPS), with clocks in sync.
- Correct trusted proxies on every PosternProxy server (see below) so logged client IPs are real visitors, not an upstream proxy.
1. Central engine and LAPI#
Install the CrowdSec engine on the central host per the current CrowdSec documentation, then add the HTTP/web collections so it understands web attacks:
sudo cscli collections install crowdsecurity/base-http-scenarios
sudo cscli hub update && sudo cscli hub upgradeEnroll with the CrowdSec console only if your policy allows it; threat-intel sharing is opt-in and should stay off unless deliberately enabled.
2. Enroll each edge bouncer#
On the central LAPI, register a bouncer per edge and capture the API key:
sudo cscli bouncers add posternproxy-edge-1On the edge node, install the firewall bouncer and point it at the central LAPI URL with that key (configure TLS; do not use plaintext across hosts):
sudo apt-get install crowdsec-firewall-bouncer-nftables
# Set api_url (central LAPI) and api_key in the bouncer config, then:
sudo systemctl restart crowdsec-firewall-bouncerRepeat per edge with a distinct bouncer identity.
3. Allowlists#
Protect known-good sources so remediation never locks out operations:
sudo cscli allowlists create infra -d "admin and internal ranges"
sudo cscli allowlists add infra 192.0.2.0/24 100.64.0.0/10Always allowlist your admin/jump ranges, your Tailscale CGNAT range, and — if you also front with a CDN — the CDN edge ranges (see the CDN caveat below).
4. Remediation policy#
- Bounded decisions: keep ban durations finite; never rely on permanent silent bans. Review default scenario durations.
- Fail-open vs fail-closed: decide what a bouncer does if the LAPI is unreachable. Fail-open preserves availability; fail-closed preserves protection. Choose per your risk posture and test it by stopping the LAPI.
- Coexistence with fail2ban: PosternProxy’s installer configures a fail2ban jail. Running both can double-ban or conflict. Either scope fail2ban to the management login path and let CrowdSec handle web traffic, or disable the overlapping jail — give each signal one owner.
5. The CDN caveat (critical)#
A firewall bouncer bans the connecting IP. If PosternProxy sits behind a CDN (for example Cloudflare), the connecting IP is the CDN edge — a firewall ban would block the CDN for everyone, not the attacker.
Behind a CDN:
- Do not firewall-ban at the origin. Allowlist the CDN ranges in the bouncer.
- Enforce on the real client IP at the application layer instead (the CDN’s own WAF / rate limiting, or an app-layer bouncer keyed on the forwarded client IP), and make sure PosternProxy’s Trusted Proxies are set so the real client IP is recovered and logged.
The firewall bouncer is the right tool when the PosternProxy node is the direct edge (no CDN in front).
6. PosternProxy-specific integration#
- Trusted proxies drive the logged IP. CrowdSec acts on the IPs in your logs. Configure Trusted Proxies per server so the logged client IP is the real visitor; otherwise CrowdSec may ban your own proxy.
- Access lists are complementary. Use access lists for static allow/deny and origin lockdown; use CrowdSec for dynamic, reputation- and behaviour-driven bans. They operate independently.
- Multi-server consistency. Roll the same bouncer config and allowlists to every edge with your configuration management; PosternProxy manages Caddy config, not the CrowdSec layer. See Provisioning.
7. Operations#
- Status and metrics:
cscli metrics,cscli decisions list,cscli alerts list. - Updates:
cscli hub update && cscli hub upgradeon a schedule; review scenario changes before rolling to all edges. - Testing: validate parsing with
cscli explain, and canary a new scenario on one edge before fleet-wide rollout. - SIEM: forward CrowdSec alerts and decisions to your SIEM for audit and correlation.
Exact package names, repository setup and config paths evolve — follow the current CrowdSec documentation for your OS and version. The PosternProxy-specific points above (trusted proxies, the CDN caveat, fail2ban coexistence, access-list interplay) are the parts that matter for this deployment.