Docs cipi.yml Web panel API MCP Guides Compare GitHub Telegram channel
  1. Home
  2. Guides
  3. Block attackers automatically with CrowdSec on a Laravel server
Security

Block attackers automatically with CrowdSec on a Laravel server

What CrowdSec is and how it differs from Fail2ban and a WAF, enabling it safely on a Cipi server, the allowlists that keep you, your CDN and your Git provider from being banned, checking what it blocks, the break-glass rescue if you lock yourself out, and how to remove it.

By Updated 3 min read

Every public server is probed all day: bots looking for /wp-login.php, .env files, old admin panels, known exploits. They rarely get in, but they fill your logs and waste resources, and the occasional one finds something. CrowdSec spots that behaviour in your logs and blocks the source at the firewall, helped by a blocklist shared by its whole community. On Cipi it's one command, with guards so it can't lock you out.

Key ideas, in plain words#

TermMeaning
EngineThe CrowdSec service that reads logs and decides
ScenarioA pattern of bad behaviour, e.g. "many 404s on admin paths"
DecisionA ban on an IP, for a duration
BouncerThe part that enforces decisions; here, the firewall
Community blocklistIPs reported as attacking by many CrowdSec users
AllowlistAddresses that must never be banned
Step 1 of 5A bot probes your site

Requests hit Nginx like any visitor and are written to each app's access log (/home/*/logs/nginx-*.log).

Before you start#

  • A Cipi server with at least 512 MB of free RAM.
  • If the server is behind Cloudflare's proxy (orange cloud): run sudo cipi zt enable first. It configures the real visitor IP (and closes no ports). Without it, Cipi refuses to enable CrowdSec, to avoid banning Cloudflare.
  • Note your own public IP (curl -s ifconfig.me from your laptop) and any office or CI addresses.

1. Enable it#

bash
ssh cipi@YOUR_SERVER
sudo cipi crowdsec enable
sudo cipi crowdsec status
What enable doesWhy
Installs the engine and the firewall bouncerDetection plus enforcement
Allowlists your current SSH session's IP firstYou can't ban yourself while enabling
Allowlists Let's Encrypt, localhost, private rangesCertificates keep renewing
Allowlists GitHub, Bitbucket and GitLab webhook ranges (refreshed weekly)Push-to-deploy keeps working
Starts a small rescue listenerA way back in if you're ever banned (step 4)
Installs the nginx, sshd and linux collectionsThe scenarios that matter on a web server

2. Allow the addresses you trust#

bash
sudo cipi crowdsec allow 203.0.113.42      # office
sudo cipi crowdsec allow 198.51.100.7      # CI runner, uptime monitor

Remove one with sudo cipi crowdsec unallow <ip>. Allowlist monitors and CI that hit the site often, or run security scans against it (for example Hackly's scanner IP).

3. See what it blocks#

bash
sudo cipi crowdsec status        # engine, bouncer, rescue, active decisions
sudo cipi ban list               # banned IPs, CrowdSec and Fail2ban together
sudo cipi ban unban 192.0.2.10   # lift a ban everywhere at once

Within a day you'll usually see bans for scanners that probed paths your apps don't have.

4. If you ban yourself: the rescue#

Changed network and can't reach the server any more? Cipi prepared a way back:

bash
# print it now, store it OFF the server (password manager)
sudo cipi crowdsec rescue token
Step 1 of 4You're banned

Your new IP triggered a ban (or a typo'd password did, in Fail2ban).

The rescue grants nothing except the ability to connect again; wrong tokens are throttled. sudo cipi crowdsec rescue rotate makes a new token at any time. The provider's web console is always the last resort.

5. Remove it#

bash
sudo cipi crowdsec disable

Firewall rules are flushed before the packages are removed, so nothing stays blocking.

Your defence layers#

LayerStopsOn Cipi
Firewall (UFW)Everything except 22, 80, 443Always on
Fail2banSSH password guessingAlways on
CrowdSecScanners, probes, known attackers on the webcipi crowdsec enable
Cloudflare proxy / Zero TrustBad requests before they reach you; closed portsZero Trust guide
PatchingKnown vulnerabilities in PHP and NginxNightly (CVE case study)
Your codeApp-level bugsCheckpoint, Hackly

Troubleshooting#

ProblemFix
enable refused: proxy without real IPsudo cipi zt enable first (it closes nothing)
enable refused: not enough RAMFree memory or keep Fail2ban only
A colleague is bannedsudo cipi ban unban <ip>, then sudo cipi crowdsec allow <ip>
Uptime monitor shows outagesAllowlist the monitor's IPs
Git pushes stopped deployingRun sudo cipi crowdsec refresh to update webhook ranges; check cipi ban list
You're locked outRescue curl (step 4), or the provider's web console

Questions

What does CrowdSec do?

It reads your web and SSH logs, recognises attack behaviour (vulnerability scanners, credential stuffing, exploit probes, brute force), and a firewall "bouncer" drops traffic from those IPs. It also receives a community blocklist of IPs other users have seen attacking.

Do I still need Fail2ban?

Cipi keeps both. Fail2ban guards SSH logins; CrowdSec adds behaviour-based detection on web traffic and the shared blocklist. cipi ban list shows bans from both.

Is it a WAF?

No. A WAF inspects each request and blocks bad ones; CrowdSec blocks IPs after it has seen bad behaviour. For request filtering, put Cloudflare in front (guide).

Can it ban my own users?

It bans on behaviour, not on normal browsing. Shared IPs (offices, mobile carriers) can rarely be caught; allowlist known addresses with cipi crowdsec allow.

I'm behind Cloudflare. Will it ban Cloudflare?

Cipi refuses to enable it behind a proxy until the real visitor IP is configured, which cipi zt enable does. Then CrowdSec sees and bans real visitors, not Cloudflare.

How much memory does it need?

Cipi refuses below 512 MB of available RAM. On small servers, keep Fail2ban only.

Does it share my data?

CrowdSec's community blocklist works by sharing signals about attacking IPs with CrowdSec. Read their privacy terms; Cipi doesn't send your app data anywhere.

How do I remove it?

sudo cipi crowdsec disable flushes its firewall rules first, then removes it. Nothing is left blocking traffic.

Try it on your own server

Free and open source. One command on a fresh Ubuntu 24.04 or 26.04 VPS.

wget -O - https://cipi.sh/setup.sh | bash
Read the quickstart