WIUNIX ACADEMY
CrowdSec and Nginx: trustworthy logs, private LAPI and reversible IP bans
Page 2 of 5. Review the earlier steps and prerequisites before continuing.
YOUR SYSTEM. YOUR STEPS.
Where are you working?
Choose your OS and version. The prerequisites, commands and troubleshooting follow your environment.
USE YOUR OWN VALUES
Configure this tutorial
Set the example values for your environment; related explanations and copy panels update together. Never enter passwords, private keys or tokens. Values stay in this tab and are not sent to the server or share links. Check actual DNS, certificates and network policy before running commands.
Different IP addresses, domains or ports? Open the settings below, change the values and select “Apply to tutorial”, then copy the updated commands.
Set values for my environment7 editable values
LET’S BUILD
Download the reviewed upstream releases
Reviewed 2026-11-05: engine 1.8.2 and bouncer 1.2.3 are stable; 1.2.4-rc1 remains a prerelease. Engine and HTTP-library hashes were computed from downloaded bytes in this review; the bouncer hash is retained from the earlier article review. These hashes are not vendor signatures. Check current security/release notes before later use.
Download to exclusive files and verify each hash before extraction. Do not run either installer. Pin pure-Lua lua-resty-http 0.17.1 directly so no LuaRocks interpreter/ABI selection is hidden; this is a reviewed dependency version, not a latest-version claim. A failed partial download is retained and must be investigated rather than overwritten.
Dedicated disposable VM · terminal
set -eu
sudo python3 - <<'PY'
from pathlib import Path
import os,urllib.request,hashlib,tarfile
r=Path('/srv/academy-crowdsec')
items=[
('engine.tgz','https://github.com/crowdsecurity/crowdsec/releases/download/v1.8.2/crowdsec-release.tgz','6e0b2add0ff3231dca3db7146834d7fea028215b915e2da39ebe30fc9f11436f','crowdsec-v1.8.2'),
('bouncer.tgz','https://github.com/crowdsecurity/cs-nginx-bouncer/releases/download/v1.2.3/crowdsec-nginx-bouncer.tgz','8cb0c176f01bda3a5fc5493d20bcd7261630c7dfbd60c00b2bff8eefc8fe84d5','crowdsec-nginx-bouncer-v1.2.3'),
('resty-http.tgz','https://github.com/ledgetech/lua-resty-http/archive/refs/tags/v0.17.1.tar.gz','f52a0538b20a2d45025f318c18a138b78f6f88f07713dd0ed502183cb3d16f17','lua-resty-http-0.17.1')]
for filename,url,digest,top in items:
dest=r/'downloads'/filename
if (r/top).exists() or (r/top).is_symlink():
raise SystemExit('Release directory already exists')
fd=os.open(dest,os.O_WRONLY|os.O_CREAT|os.O_EXCL|os.O_NOFOLLOW,0o644)
h=hashlib.sha256()
with os.fdopen(fd,'wb') as out, urllib.request.urlopen(url,timeout=60) as response:
while True:
block=response.read(1024*1024)
if not block: break
h.update(block);out.write(block)
if h.hexdigest()!=digest: raise SystemExit('SHA256 mismatch: '+filename)
print(filename+': SHA256 OK')
with tarfile.open(dest,'r:gz') as archive:
for m in archive.getmembers():
path=Path(m.name)
if path.is_absolute() or '..' in path.parts or not path.parts or path.parts[0]!=top:
raise SystemExit('Unsafe archive path')
if not (m.isfile() or m.isdir()): raise SystemExit('Unexpected archive member')
archive.extractall(r)
PY
sudo cp -r '/srv/academy-crowdsec/crowdsec-v1.8.2/config/patterns' '/srv/academy-crowdsec/config/patterns'
sudo '/srv/academy-crowdsec/crowdsec-v1.8.2/cmd/crowdsec/crowdsec' -version
All three SHA256 checks pass and the engine reports 1.8.2; any mismatch stops extraction.
LET’S BUILD
Verify the selected web runtime
Build the reviewed OpenResty source exclusively inside the new lab root. Lua/cjson are bundled; the verified build changes no system web binary or service. Two build jobs may take several minutes. Plan supervision and confinement separately for a persistent service.
Dedicated disposable VM · terminal
set -eu
sudo python3 - <<'PY'
from pathlib import Path
import urllib.request,hashlib,os,tarfile
r=Path('/srv/academy-crowdsec'); dest=r/'downloads/openresty.tgz'
for p in (r/'openresty',r/'openresty-1.31.8.1'):
if p.exists() or p.is_symlink(): raise SystemExit('OpenResty path already exists')
fd=os.open(dest,os.O_WRONLY|os.O_CREAT|os.O_EXCL|os.O_NOFOLLOW,0o644)
h=hashlib.sha256()
with os.fdopen(fd,'wb') as out, urllib.request.urlopen('https://openresty.org/download/openresty-1.31.8.1.tar.gz',timeout=60) as response:
while True:
block=response.read(1024*1024)
if not block: break
h.update(block);out.write(block)
if h.hexdigest()!='b569c63b420f80a4ac8466f2deffe73ed93ab760026532e039c3658409a997f4':
raise SystemExit('OpenResty SHA256 mismatch')
with tarfile.open(dest,'r:gz') as archive:
for m in archive.getmembers():
p=Path(m.name)
if p.is_absolute() or '..' in p.parts or not p.parts or p.parts[0]!='openresty-1.31.8.1':
raise SystemExit('Unsafe archive path')
if not (m.isfile() or m.isdir()): raise SystemExit('Unexpected archive member')
archive.extractall(r)
print('OpenResty SHA256 OK; source extracted into new directory')
PY
sudo sh -c 'set -eu; umask 022; PATH=/usr/sbin:/usr/bin:/sbin:/bin; export PATH; cd "/srv/academy-crowdsec/openresty-1.31.8.1"; ./configure --prefix="/srv/academy-crowdsec/openresty" --with-pcre-jit --with-http_ssl_module; make -j2; make install'
sudo chmod 0755 '/srv/academy-crowdsec/openresty/nginx/sbin/nginx'
sudo '/srv/academy-crowdsec/openresty/nginx/sbin/nginx' -V
The verified private OpenResty binary reports its version and build options.
LET’S BUILD
Edit the isolated engine files
Open each reserved file in the following panels. Save the exact YAML; the intentionally absent online_client section and -no-capi prevent community-API communication. LAPI is loopback-only; local machine credentials authenticate the log processor, while a separate API key authenticates the bouncer.
Dedicated disposable VM · terminal
sudo nano '/srv/academy-crowdsec/config/engine.yaml' '/srv/academy-crowdsec/config/acquis.yaml' '/srv/academy-crowdsec/config/profiles.yaml' '/srv/academy-crowdsec/config/simulation.yaml'
Four dedicated files saved; no system CrowdSec configuration changed.
Engine and local API
File content, not a shell command.
common:
daemonize: false
log_media: file
log_level: info
log_dir: /srv/academy-crowdsec/logs
config_paths:
config_dir: /srv/academy-crowdsec/config
data_dir: /srv/academy-crowdsec/data
simulation_path: /srv/academy-crowdsec/config/simulation.yaml
hub_dir: /srv/academy-crowdsec/hub
index_path: /srv/academy-crowdsec/hub/.index.json
notification_dir: /srv/academy-crowdsec/notifications
plugin_dir: /srv/academy-crowdsec/plugins
crowdsec_service:
acquisition_path: /srv/academy-crowdsec/config/acquis.yaml
parser_routines: 1
cscli:
output: human
db_config:
type: sqlite
db_path: /srv/academy-crowdsec/data/crowdsec.db
use_wal: false
api:
client:
credentials_path: /srv/academy-crowdsec/config/local-api.yaml
server:
listen_uri: 127.0.0.1:18081
profiles_path: /srv/academy-crowdsec/config/profiles.yaml
trusted_ips:
- 127.0.0.1
prometheus:
enabled: true
level: full
listen_addr: 127.0.0.1
listen_port: 18082
Acquire only this Nginx access log
File content, not a shell command.
filenames:
- /srv/academy-crowdsec/logs/access.log
labels:
type: nginx
Short decisions for local IP alerts
File content, not a shell command.
name: local_ip_ban
filters:
- Alert.Remediation == true && Alert.GetScope() == "Ip"
decisions:
- type: ban
duration: 2m
on_success: break
Explicit lab simulation setting
File content, not a shell command.
simulation: false