Setting up npmplus with CrowdSec Integration on Host
Let's be real, raw-dogging the open internet without a solid WAF in 2026 is just asking to get your servers cooked. In this writing, we're setting up npmplus (nginxproxymanager with http/3 support and crowdsec integration) and hooking it up directly to a host-level CrowdSec instance. This setup will effortlessly bounce bad actors before they even touch your web services.
Prerequisites
- Docker, Docker Compose, Crowdsec installed on your host.
- A basic text editor (e.g.,
nano,vim). - 2 or more brain cells.
- patience to read all of this thing.
Step 1: Set up the npmplus docker-compose.yml
We're going to run npmplus using Docker. Create a docker-compose.yml file and paste the following configuration.
Warning
Important Notice on Network Mode: Notice that network_mode: host is being used here. This means the npmplus container completely ignores Docker's default network isolation and binds directly to your host's network interfaces. No ports mapping needed—npmplus is basically moving in and claiming ports 80, 443, and 81 rent-free.
name: npmplus
services:
npmplus:
container_name: npmplus
image: docker.io/zoeyvid/npmplus:latest
restart: unless-stopped
network_mode: host
cap_drop:
- ALL
cap_add:
- NET_BIND_SERVICE
- SETGID
- BPF
- PERFMON
- NET_ADMIN
- NET_RAW
security_opt:
- no-new-privileges:true
dns:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
- 8.8.4.4
volumes:
- ./data:/data
environment:
- "TZ=Asia/Shanghai" # Change it to your timezone
- "ACME_EMAIL=your@email.whatever" # Change it to yo email(ofc)
- "ENABLE_MPTCP=true" # Optional but recommeded
- "NGINX_QUIC_BPF=true" # Optional but recommeded
- "LOGROTATE=true" # must be true to use crowdsec on host machine
- "TRUST_CLOUDFLARE=true" # Optional but recommeded
Key Environment Variables Explained: I have un-commented and customized the following environment variables for this setup:
TZ=Asia/Shanghai: Configures the timezone inside the container so your logs actually make chronological sense.ACME_EMAIL=your@email.whatever: Sets the registration email used by Let's Encrypt / ZeroSSL for SSL certificate issuance and expiration panics.ENABLE_MPTCP=true: Enables Multipath TCP (MPTCP) for more resilient connections, requiringnetwork_mode: hostto function.NGINX_QUIC_BPF=true: Leverages NGINX'squic_bpffor ultra-fast HTTP/3 QUIC packet routing (this specifically requires theBPF,PERFMON, andNET_ADMINcapabilities enabled incap_add).LOGROTATE=true: Tells npmplus to generate and write standard local access/stream logs inside the container and enables daily rotation.TRUST_CLOUDFLARE=true: Automatically whitelists Cloudflare proxy IPs so NGINX correctly logs the real visitor IP instead of just Cloudflare's edge servers.
Step 2: Generate a CrowdSec Bouncer API Key
Next, we need to create a bouncer API key on the host machine using CrowdSec's CLI (cscli). This key securely links npmplus to your local CrowdSec instance. Run the following command on your host:
sudo cscli bouncers add npmplus-bouncer
Save the generated API key somewhere safe, as you will need it in the next step!
Step 3: Configure the CrowdSec Bouncer
Open or create the CrowdSec bouncer configuration file for npmplus:
sudo nano /path/to/your/npmplus/data/crowdsec/crowdsec.conf
Populate the file with the following content. Make sure to replace (PORT THAT YOU ARE RUNNING CROWDSEC DEFAULT IS 8080) with your actual Local API port, and slam your API key from Step 2 into the API_KEY field.
ENABLED=true
API_URL=http://127.0.0.1:PORT THAT YOU ARE RUNNING CROWDSEC DEFAULT IS 8080
# Authentication options, either using an API key or TLS client certificate.
API_KEY=CHANGE_THIS_TO_YOUR_API_KEY_IN_STEP2
USE_TLS_AUTH=false
TLS_CLIENT_CERT=/path/to/client.crt #NO NEED vvvvvvvvvvvvv
TLS_CLIENT_KEY=/path/to/client.key #NO NEED IF USE_TLS_AUTH=false
CACHE_EXPIRATION=1
# bounce for all type of remediation that the bouncer can receive from the local API
BOUNCING_ON_TYPE=all
FALLBACK_REMEDIATION=ban
REQUEST_TIMEOUT=3000
UPDATE_FREQUENCY=10
# By default internal requests are ignored, such as any path affected by rewrite rule.
# set ENABLE_INTERNAL=true to allow checking on these internal requests.
ENABLE_INTERNAL=false
# live or stream
MODE=live
# exclude the bouncing on those location
EXCLUDE_LOCATION=
#those apply for "ban" action
# /!\ REDIRECT_LOCATION and RET_CODE can't be used together. REDIRECT_LOCATION take priority over RET_CODE
BAN_TEMPLATE_PATH=/data/crowdsec/ban.html
REDIRECT_LOCATION=
RET_CODE=
#those apply for "captcha" action
#valid providers are recaptcha, hcaptcha, turnstile
CAPTCHA_PROVIDER=
# Captcha Secret Key
SECRET_KEY=
# Captcha Site key
SITE_KEY=
CAPTCHA_TEMPLATE_PATH=/data/crowdsec/captcha.html
CAPTCHA_EXPIRATION=3600
APPSEC_URL=http://127.0.0.1:7422
APPSEC_FAILURE_ACTION=deny
APPSEC_CONNECT_TIMEOUT=
APPSEC_SEND_TIMEOUT=1000
APPSEC_PROCESS_TIMEOUT=30000
ALWAYS_SEND_TO_APPSEC=false
SSL_VERIFY=true
Step 4: Install Required CrowdSec Collections
CrowdSec needs to know what it's actually looking for (it's smart, but it's not a mind reader). We're going to install the dedicated npmplus collection along with a few foundational Linux and HTTP scenarios so it knows how to vibe check incoming traffic. Run these on the host:
sudo cscli collections add ZoeyVid/npmplus
sudo cscli collections add crowdsecurity/linux
sudo cscli collections add crowdsecurity/base-http-scenarios
sudo cscli collections add crowdsecurity/sshd
Step 5: Setup Custom AppSec Configuration
Create and modify the custom AppSec ruleset configuration file for npmplus:
sudo nano /etc/crowdsec/appsec-configs/npmplus-custom.yaml
Paste the following YAML configuration:
name: npmplus-custom-appsec
default_remediation: ban
inband_rules:
- crowdsecurity/base-config
- crowdsecurity/vpatch-*
- crowdsecurity/generic-*
outofband_rules:
- crowdsecurity/experimental-*
- crowdsecurity/appsec-generic-test
What this does: This configuration actively defines Application Security (WAF) behaviors. It sets the default action for malicious requests to ban. The inband_rules analyze traffic synchronously (holding the request) to instantly drop well-known bad payloads like generic exploits. The outofband_rules evaluate traffic asynchronously (without slowing down legitimate requests) for experimental pattern detection. It's basically a highly-efficient bouncer for your website.
Step 6: Configure CrowdSec to Gather Logs from npmplus
CrowdSec needs to actually read the logs that npmplus is spitting out so it can catch the bad guys in the act. Let's point it to the right place.
Create and edit this file as root:
sudo nano /etc/crowdsec/acquis.d/npmplus.yaml
Paste in the following configuration (make sure the path matches where you mounted your data volume in step 1!):
filenames:
- /path/to/your/npmplus/data/nginx/*.log
labels:
type: npmplus
poll_without_inotify: true
---
filenames:
- /path/to/your/npmplus/data/nginx/*.log
labels:
type: modsecurity
poll_without_inotify: true
---
listen_addr: 127.0.0.1:7422
appsec_config: npmplus-custom-appsec
name: appsec
source: appsec
labels:
type: appsec
Step 7: Verify Connections & Restart CrowdSec
Caution
Double-check your API_URL and API_KEY! If npmplus can't connect to the CrowdSec Local API, it panics, aggressively fail-closes, and blocks all your web traffic entirely. It's a security feature, not a bug, but you still don't want to accidentally ban yourself from your own site đź’€.
Once you have verified the configuration is correct, restart the CrowdSec service to apply everything:
sudo systemctl restart crowdsec
Finally, just spin up your npmplus docker container (docker compose up -d) and enjoy your ultra-fast, ridiculously secure reverse proxy. Your servers are officially safe from the skiddies. W.