Skip to content
Projets

À propos

Web manager for nginx + ModSecurity v3 + OWASP CRS: every rule change is checked, sandbox-tested against real traffic and approved before it goes live, with rollback, a hash-chained audit log and an optional self-hosted LLM to triage events.

IA et apprentissage automatique

Comment ces chiffres sont mesurés

What you can do

  • Collector: the ModSecurity JSON audit log (copytruncate and rename rotation, oversized and malformed records); passwords, tokens and other sensitive fields are masked before anything is stored.
  • Overview and events: drag across the timeline to zoom in, or pick any range up to 31 days; filters stay in the URL; event detail with every matched rule; one click to draft an exclusion or a block.
  • Temporary IP blocks (new in 0.4.24, optional): fail2ban on a mail server, a SOAR playbook or an approver blocks a single address for a while; one nginx deny list covers every site. See Temporary IP blocks.
  • Country blocks (new in 0.4.28, optional): limit a site to some countries, or block some countries, with lists from the five regional Internet registries, refreshed daily. Each site's limit is a rule through the change workflow; Rules → Country limits shows every site: who may reach it, what was refused, "modify" and "add limit". See Country blocks.

Progression mesurée des étoiles

in 24h
0
in 7 days
+1
in 15 days
+2
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

jt-waf-mgr v0.5.55

English · 繁體中文 · 日本語

License Last commit Python Vue ModSecurity OWASP CRS OWASP

🌐 Project site →

A self-hosted web manager for nginx + libmodsecurity v3 + OWASP CRS 4: read what the WAF did, tune it through an evidence-checked, sandbox-tested and approved change workflow, let a self-hosted LLM review the events, and get notified on Teams, Telegram, Zulip, Slack, Discord, Nextcloud Talk, e-mail or a signed webhook.

By Jason Tools Co., Ltd. · License: AGPL-3.0

Overview


Why jt-waf-mgr?

libmodsecurity v3 has no management interface. Rules, exclusions and blocks are configuration files; tuning means reading JSON audit logs and editing files by hand on a production reverse proxy. jt-waf-mgr turns the audit log into something you can read, and every change into a workflow you can trust:

  • See what happened: blocked / logged, by site, attack type, source (with country and network owner), rule and time; "blocked only by the CRS score" first, because those are the likely false positives.
  • Change safely: templates (exclusion, confident block, redaction, plugin toggle, expert raw rule) → static checks (regex sanity, ReDoS) → evidence from the access logs → a throwaway nginx sandbox with the production configuration and regression samples → approval → a small root program that tests, reloads, health-checks and restores on failure → versions with one-click rollback.
  • Let a model help, never decide alone: a scheduled analysis with your own OpenAI-compatible LLM server proposes narrow blocks for probes, the narrowest exclusion for false positives, and raises alerts — everything is validated by the program, loosening always needs a person.
  • Trust the trail: hash-chained, append-only audit trail anchored outside the database and in syslog; signed releases; fingerprints of every nginx / ModSecurity / CRS file; compliance views for ISO/IEC 27001:2022, Taiwan's Cyber Security Management Act and OWASP Top 10:2025.

Three ways to use it

The three ways to use jt-waf-mgr

  1. nginx is the web server: the sites live on the nginx host itself (static files, PHP-FPM, ...). ModSecurity inspects every request before nginx answers it, and jt-waf-mgr manages the rules, approvals and analysis.
  2. nginx as a reverse proxy: the sites run on other servers; nginx with ModSecurity sits in front of them and forwards only the requests that pass the WAF.
  3. Both on one host: some sites are served by this nginx, others are proxied to other servers. The same WAF, the same rules and the same interface cover them all, and the WAF is switched on site by site.

In every case jt-waf-mgr runs on the nginx host, beside the WAF: requests never pass through it, and if it stops, nginx and ModSecurity keep working with the last rules.

nginx examples for a reverse proxy (a web site, WebSocket, Synology DSM, QNAP QTS, and the reason for each setting): reverse proxy examples.

When it fits — and when it does not

jt-waf-mgr does not sit in the request path: nginx with ModSecurity and the CRS inspects every request, exactly as without it, and if jt-waf-mgr stops, the WAF keeps working with the last rules. What it adds runs beside nginx on the same host; that is where the limits are.

A good fit

  • One nginx host (web server, reverse proxy or both) with libmodsecurity v3, run by a small team that wants every WAF change checked, approved, traced and audited (ISO/IEC 27001, Taiwan's Cyber Security Management Act).
  • Access logs up to roughly 9 million lines in the window the evidence check reads (it reads about 10,000 lines a second and stops after 15 minutes). In production: a few dozen sites, about 150,000 requests a day, 7.3 million lines.
  • WAF events: the collector stores about 750 events a second on one CPU core (measured on a synthetic log), far more than an ordinary site raises; repeated events of an attack flood are merged.

Not a fit (yet)

  • Sites spread over several nginx nodes behind a load balancer — the usual shape of large, high-traffic sites: only single-node mode for now (multi-node management is paused).
  • Very large log volumes (tens of millions of requests a day kept for weeks): the evidence check of a change stops before it has read everything, and a person has to justify the change without it.
  • Other proxies or engines (Apache, HAProxy, Envoy, Traefik, ModSecurity v2, Coraza).
  • A fully automatic WAF: loosening a rule always needs a person.

For a large site, the per-request cost of ModSecurity with the CRS (the same with or without jt-waf-mgr) is worth measuring on your own traffic before you rely on it; a CDN or cloud WAF is the other road.

Features

  • Collector: the ModSecurity JSON audit log (copytruncate and rename rotation, oversized and malformed records); passwords, tokens and other sensitive fields are masked before anything is stored.
  • Overview and events: drag across the timeline to zoom in, or pick any range up to 31 days; filters stay in the URL; event detail with every matched rule; one click to draft an exclusion or a block.
  • War room (new in 0.4.56): Overview > War room opens a board for a wall screen in a new tab: a flat map and a 3D globe of the last 30 minutes, or a longer range up to 7 days, or a demo with made-up attacks (source countries, blocked / logged, a tracer per new batch towards your WAF), the decision flow, site activity in 2-minute cells, a false-positive review desk, AI analysis and threat intelligence, and alerts and changes, rotating; no address, path or query on the wall.
  • Temporary IP blocks (new in 0.4.24, optional): fail2ban on a mail server, a SOAR playbook or an approver blocks a single address for a while; one nginx deny list covers every site. See Temporary IP blocks.
  • Country blocks (new in 0.4.28, optional): limit a site to some countries, or block some countries, with lists from the five regional Internet registries, refreshed daily. Each site's limit is a rule through the change workflow; Rules → Country limits shows every site: who may reach it, what was refused, "modify" and "add limit". See Country blocks.
  • Request volume (new in 0.4.23): every request in the nginx access logs, counted per site and hour (2xx, 3xx, 4xx, 5xx, 403, 444, 429, external, bytes; numbers only, no address, URL or user agent), next to what the WAF blocked, so the WAF numbers have a denominator. Switched on or off, and its alerts set, in the admin Settings ("Request volume"); optional alerts, off by default: a traffic spike (N times the site's usual hour over the previous 7 days) or many 5xx answers.
  • WAF model: how a request is decided on these sites (engine per site, scoring, thresholds, exclusions, confident blocks), drawn from the live configuration.
  • Rules: every rule with where it comes from (OWASP CRS and its version, a CRS plugin, imported at adoption, a change by a person, an API token or the event analysis), hits per day, syntax-highlighted text. New in 0.4.23: who wrote each rule, with a filter and per-author counts: OWASP CRS, an OWASP CRS plugin, a third-party plugin, ModSecurity base settings, jt-rules (rules jt-waf-mgr generates from a form, and the jt-rules pack) or this site (hand-written: imported at adoption, raw rules, nginx vhost files).
  • Change workflow: single changes or one bundle (one approval, one version, one reload), upload of rule files, evidence, sandbox, health URLs, approval rules (the proposer cannot approve; single-admin mode with a fresh one-time code for loosening), automatic tightening within strict limits, rollback.
  • First-tier LLM (event analysis, self-hosted): candidates grouped by the path a rule sees; one schema-constrained request per batch; the program, not the model, decides what is proposed (narrow anchored regex, never matching common paths, regression samples or paths the organisation itself uses; exclusions are one exact path, specific rules and request parts only, and need a one-time code to approve); outside sources probing for secret, backup or configuration file names, or one address trying many paths, are probes by the program's own rule; a path called an attack before is not loosened on one "false positive" verdict; summaries of every run. AI can be wrong, in both directions: the model only suggests; loosening always needs a person, only tightening that passed every check may apply on its own. Which LLM to use: see Event analysis: which LLM.
  • AI analysis of one event: a button on every event sends it with what is around it (the same source over the hour and 30 days, the same site and path over 7 days, the rules) to your local LLM: attack, false positive or unclear, why, and what to do (block the address, block the request, a narrow exclusion, watch). The buttons open the usual forms; every block and exclusion is checked and approved as always.
  • Periodic WAF review: every 3 hours (stored, and sent to your notification channels): requests blocked by the CRS score alone with possible false blocks first, new internal hits, outside attacks that got through, what was done automatically, one line per focus site.
  • Second-tier LLM (threat intelligence): a stronger LLM, local (OpenAI-compatible) or cloud (OpenAI-compatible, Google Gemini or Anthropic), searches the web every few hours for new vulnerabilities in the list of web applications the program guesses and a person confirms (this host's web-facing packages: about 50 products; the CRS; the applications the sites run: about 300 recognised from the paths they answer or their home page), above all those exploited in the wild. Only product names and versions leave the host, with a few facts for the vulnerabilities' preconditions (operating system, architecture, C library). Local models search through an MCP server (for example SearXNG); Anthropic and OpenAI's own API can use the provider's web search instead. The program reads only https pages on an allow-list, and "exploited" counts only when it read the CISA catalog itself in that run, or -- with the KEV catalog switched on (downloaded daily, about 1.5 MB) -- when the catalog lists it. A product can be confirmed by name alone; an exploited vulnerability that affects (or, without a version, may affect) you raises a critical alert. A Debian package installed here is checked against its own change log and, optionally, the Debian security tracker (fixed in the installed version, not affected, or another program's CVE: set aside; fixed in a newer package: update it). With a Synology product (DSM or a package) or a QNAP product (QTS, QuTS hero or an app) it can read that vendor's own advisory feed daily and hand the advisories of the last months to the model to compare the affected and fixed versions. Optionally it reads the back-end hosts' versions too: nginx does not pass a back-end's Server header on, so the answer headers of the private addresses proxy_pass points to are read directly, the back-end nginx, Apache and PHP versions are listed in the software list, and a back-end nginx that nginx.org's advisories list as affected raises an alert. For one seen in the URL, a header or a parameter's name (in the query string, a form or an upload) it writes one virtual patch per vulnerability for every site it reaches (a narrow confident block, checked like any change: the evidence where the access logs can show it, always the sandbox) and applies it without a person once the checks pass, within the daily limit; one for an exploited vulnerability that affects you goes past the limit, and a critical alert asks a person if its checks fail. The program searches every product, and the languages and frameworks it is built on (a PHP flaw reaches every PHP application), itself each run; an announced security release raises an alert, and the search runs again once it is out. A person can also hand it a page or a text (a news article, a vendor advisory) to read now. Token limits per day and month; a run ends within 45 minutes.
  • IP reputation: the IP lookup puts together what this site saw of an address with public lists downloaded once a day (Spamhaus DROP, FireHOL level 1, abuse.ch Feodo, Emerging Threats, CINS Army, blocklist.de, Tor exit nodes; matched on the host), Shodan InternetDB and your own MISP, with a verdict and its reasons. Off by default; nothing is blocked by itself.
  • CrowdSec virtual patching rules: the CrowdSec Hub's appsec rules (MIT) are synced daily (or uploaded offline) and converted into ModSecurity rules on the host, only where every condition keeps its meaning. A converted rule is proposed for the sites that run the software, or for all sites when it is a cross-application flaw (a framework, library or language such as React, Spring or PHP; related to your sites through the stack their software is built on), as an ordinary change: the sandbox replays the hub's own attack requests, each must be refused by that rule, and recent requests of the sites must not be. Rules in use show when the hub updates or removes them. Threat intelligence proposes the hub's rule first for a vulnerability that affects confirmed software.
  • Application protection sets: ready-made confident blocks for one application, written from its publicly known vulnerabilities and attacks; the first set is Synology DSM (its administration APIs from the local network only, including the batch request and escaped-character ways around it); the second is QNAP QTS (the setup wizard, HBS 3's built-in session id, ../ in file names, overlong ids, shell characters in user names and session cookies; written from public write-ups, not tried on a real QNAP); Nextcloud (non-public files and directories, ../ in the path as sent, the built-in CODE server's command injection CVE-2026-110447, the updater and upgrade pages from outside) and Zimbra (administration services on the user port, several logins in one GraphQL request, LDAP wildcards in login names, internal servlet attributes as parameters, /h/rest, markup in identifier parameters) and LibreNMS (administration pages from outside, the API token as a parameter, SQL in notification, address, sort and package parameters, shell characters in device host names, quotes and line breaks in graph parameters). Every set's own requests are replayed in a real nginx + ModSecurity 3.0.9 and 3.0.17 + CRS 4.30 sandbox. The software list recognises a DSM site and the packages on it (DSM lists the APIs it serves without a login). Pick the site and the rules and propose them as one change: the usual checks, the sandbox replays each rule's own attack and ordinary requests, and a person approves it; most rules refuse requests from outside only.
  • Alerts to follow up: an attack the site may have answered, users hit by a false positive, an attack in progress, outside configuration changes, integrity problems, failed applies or backups — open until an approver marks them handled with a note; reminded until then.
  • Notifications: e-mail (SMTP, text + HTML), Telegram, Microsoft Teams (Workflows / Adaptive Card), Slack, Discord, Zulip, Nextcloud Talk and a generic webhook (HMAC-SHA256 signature); a matrix of events × channels; a test per channel; retries, rate limits and delivery records. Request content quoted in a message (URL, headers) is sent as plain text, so an attacker cannot slip in links, formatting or @-mentions.
  • OWASP CRS updates (optional, off by default): a sandboxed daily check takes the newest release of the major version in use once it has been out a week, keeps it only with a valid signature by the pinned CRS release key and stages it; the CRS page shows what is in use, what is new and what is verified. Switching to it (or back to a kept version) is a change: both versions run the same recent requests in the sandbox, a person approves, the root program re-verifies the signature, unpacks it itself, switches the crs link and switches back on any failure; 3 versions are kept to roll back. A host without the CRS can install CRS 4 the same way (its Includes go right after modsecurity.conf).
  • nginx updates and nginx's own flaws (new in 0.4.98): every 6 hours the next nginx is tried with the ModSecurity module (so the WAF is never left behind by an update) and nginx.org's security advisories are compared with the installed nginx and the features this configuration uses. Flaws in nginx itself (HTTP/2, HTTP/3, resolver...) happen before ModSecurity sees a request, so the alert says to update; the verified update is proposed for an admin to approve, and HTTP/2 or HTTP/3 can be switched off for a while (by itself for a major advisory, back on after the update) with marked, exactly reversible edits. Since 0.5.1 the way back is shown before approving: the previous package and module are kept, "roll back to the previous nginx" and "use another module" are changes like any other (also from the command line when nginx and so the page are down), a backup of the configuration and module can be downloaded first, and nginx security updates can be applied without approval if an administrator switches that on (off by default). See when nginx does not come back.
  • Log servers (syslog / SIEM): up to 8 destinations, each with its own protocol (local socket, UDP, TCP, TLS), record format (JSON, CEF, LEEF 2.0, GELF 1.1, key=value) and content (audit records, WAF events, alerts); its own queue and retries; a test send that shows exactly what went out.
  • Accounts: scrypt passwords, TOTP required for approver / admin, lockout, password policy with history and ageing, account expiry and review; API tokens with scopes and allowed source networks (tokens can propose, never approve). Recovery on the host: see Accounts and recovery.
  • Integrity and compliance: system check page, compliance page, daily verified backups with download (one-time code), configuration change history with attribution (jt-waf-mgr, registered automation, or outside); for a change from outside, what changed in each file (secret-looking values masked) and who was logged in to the host meanwhile.
  • Interface: English, 繁體中文 and 日本語; light and dark; phones and tablets; GeoIP (MaxMind GeoLite2, downloaded by its own sandboxed job) with a world map of where requests come from, drawn in the page (no map service).
Events WAF model
Event analysis Notifications
Alerts System check
Country limits by site Request volume
Threat intelligence Periodic WAF review

War room

Requirements

  • Debian 12 / 13 or Ubuntu 24.04 or later (22.04's libmodsecurity package is too old: build 3.0.9 or later yourself), Python 3.11 or newer — standard library only, no pip, no wheels: the service installs offline.
  • nginx with the ModSecurity-nginx connector, libmodsecurity 3.0.9+, SecAuditLogFormat JSON; OWASP CRS 4.x, which jt-waf-mgr can download, verify and install for you (see The OWASP CRS); rotate the audit log with copytruncate (libmodsecurity does not reopen it on reload). Starting from a fresh nginx or without CRS 4: see the ModSecurity installation guide; hosts without internet access: the offline installation guide. Adoption also works without site rule files (empty managed files are added next to the CRS rules).
  • Optional: an OpenAI-compatible LLM server on your network (llama.cpp, vLLM, Ollama…) for the event analysis (see which LLM); a MaxMind account for GeoIP.

Install

sudo mkdir -p /opt/jt-waf-mgr-install && cd /opt/jt-waf-mgr-install   # a fixed place for the releases
V=0.5.55; B=https://github.com/jasoncheng7115/jt-waf-mgr/releases/download/v$V
for f in jt-waf-mgr-$V.tar.gz jt-waf-mgr-$V.tar.gz.sig release-key.pem; do sudo curl -fsSLO $B/$f; done   # the release, its signature, the public key
openssl dgst -sha256 -verify release-key.pem -signature jt-waf-mgr-$V.tar.gz.sig jt-waf-mgr-$V.tar.gz
sudo rm -rf current && sudo mkdir current && sudo tar xzf jt-waf-mgr-$V.tar.gz -C current --strip-components=1 && cd current
sudo ./install.sh                             # verifies every file and the release signature first
sudo jt-waf-mgr check                         # parses the nginx / ModSecurity configuration
sudo jt-waf-mgr user add alice --role admin   # prints a temporary password

Where things are after installing:

  • program /usr/lib/jt-waf-mgr, command /usr/bin/jt-waf-mgr (root-owned, read-only)
  • configuration /etc/jt-waf-mgr
  • data (database, queue) /var/lib/jt-waf-mgr; the apply program /var/lib/jt-waf-mgr-apply
  • backups before each upgrade /var/backups/jt-waf-mgr
  • releases /opt/jt-waf-mgr-install; the current one unpacked in /opt/jt-waf-mgr-install/current (install, upgrade and removal run there)

Connect to the management interface

The service listens on 127.0.0.1:8095 only ([server] listen in /etc/jt-waf-mgr/config.toml) and is never exposed directly: nginx proxies a management vhost to it. The release installs an example vhost at /etc/jt-waf-mgr/nginx-vhost.conf.example. Copy it to the nginx vhost directory, for example:

sudo cp /etc/jt-waf-mgr/nginx-vhost.conf.example /etc/nginx/sites-available/waf.example.com.conf
sudo ln -s /etc/nginx/sites-available/waf.example.com.conf /etc/nginx/sites-enabled/
# (or copy it to /etc/nginx/conf.d/waf.example.com.conf)

In the copy, set:

  • server_name: the name you will open, for example waf.example.com;
  • ssl_certificate / ssl_certificate_key: the certificate (see below);
  • the allow lines: your internal networks only (or narrower: your admin network); the rest stays deny all.

Then sudo nginx -t && sudo systemctl reload nginx. The vhost has modsecurity off on purpose: the interface shows attack strings and would trigger the WAF on itself. Optional: the commented limit_req block in the example adds a brute-force brake in front of the sign-in.

The certificate, one of:

  • your organisation's internal CA, or an existing wildcard certificate;
  • Let's Encrypt: the management site is internal-only, so the HTTP-01 challenge usually can't reach it; use the DNS-01 challenge (certbot with your DNS provider's plugin), or issue it on a public host and copy it over;
  • for a lab only, a self-signed certificate (browsers will warn):
sudo openssl req -x509 -newkey rsa:3072 -nodes -days 825 -keyout /etc/ssl/private/waf.key -out /etc/ssl/certs/waf.crt -subj "/CN=waf.example.com" -addext "subjectAltName=DNS:waf.example.com"

Then open https://waf.example.com (the name you set) and sign in with the temporary password that jt-waf-mgr user add printed. The first sign-in forces a new password and the TOTP two-factor setup. Operational settings (GeoIP, LLM, analysis, notifications, request volume, networks, policy) are made in the web interface; /etc/jt-waf-mgr/config.toml only holds what the program needs to start.

Let jt-waf-mgr change rules

jt-waf-mgr writes ModSecurity files; it reads nginx's configuration (to find the sites and ModSecurity's main file), runs nginx -t and reloads nginx. The management vhost and modsecurity on; in nginx are your own one-time edits. It changes nginx itself only through approved changes made by its root program, each with nginx -t, health checks and the way back: the optional temporary IP block list (a file of deny lines you include once yourself), one marked include line per site (WAF on or off, the block page), HTTP/2 or HTTP/3 switched off for a while when nginx itself has a flaw (marked lines, put back exactly), and the nginx package with its ModSecurity module (update, rollback).

To let jt-waf-mgr change rules: arm the apply program (sudo ./install.sh --enable-apply), set the health check URLs, and adopt the existing rule files under Rules → Managed rules (an admin approves the adoption like any change). Nothing is written before that. Adoption also works without site rule files.

Switch the WAF on for a site

Sites lists every server block and whether ModSecurity runs there. For a site without it, an approver presses "Switch WAF on" and writes why: that becomes a change. The check replays the site's recent normal requests from the access logs in the sandbox with ModSecurity on and lists any it would refuse; a person approves; the root apply program adds ONE marked line right after the site's server { lines -- include <the snippet your other sites use to switch ModSecurity on>; # jt-waf-mgr: WAF on (change #N) -- runs nginx -t, reloads, checks the health URLs and puts everything back if a step fails. "Switch WAF off" removes exactly that line again (a loosening, approved like any other); a WAF switched on any other way, or a block with modsecurity off; written by hand, is left alone. Before writing, the root program computes the plan itself and goes ahead only when it matches the approved one and the files still have the checked contents.

A page for people the WAF blocked

Without one, a blocked visitor sees nginx's plain "403 Forbidden". On the Sites page, "Blocked page" puts a page in three languages with the request id (nginx's $request_id, written with server-side includes) on every site at once, or one site at a time from the table. It is a change a person approves: each server block that serves content gets one marked include line (blocks that only redirect, or that have their own 403 page, are left alone), and the root program writes the page and the snippet next to the managed rule files, runs nginx -t, reloads and checks the health URLs, putting everything back if a step fails. With modsecurity_transaction_id "$host-$request_id"; the id is also in the event: paste it into "Someone was blocked?" on the Events page. It shows for the WAF (country rules included) and the IP block list; not where a site's own nginx if answers 403 first, and not for the 403 pages of the applications behind nginx. The snippet and the page are jt-waf-mgr's own: when a release brings newer ones, "Update the page" writes them (as a change). "Remove" takes the lines out again.

The OWASP CRS

jt-waf-mgr handles the CRS. A new host only needs nginx with the ModSecurity module, a modsecurity.conf with SecAuditLogFormat JSON, a main file that Includes modsecurity.conf, and modsecurity on; plus modsecurity_rules_file … in nginx (ModSecurity installation guide). Then:

  1. Switch on "Keep the CRS current from here" on the CRS page.
  2. jt-waf-mgr downloads the newest CRS 4.x once it has been out wait_days (default 7) and verifies it against the pinned CRS signing key.
  3. "Compare in the sandbox and propose installing" creates a change.
  4. After a person approves it, jt-waf-mgr installs crs-<version>, the crs link and crs-setup.conf, and inserts the Includes right after modsecurity.conf.
  5. Adoption then adds jt-waf-mgr's managed rule files around the CRS rules.

Later CRS updates work the same way: download, verify, compare in the sandbox, a person approves, install; 3 versions are kept to roll back. Installing the CRS by hand also works (see the guide).

Temporary IP blocks (optional)

Other systems, for example fail2ban on a mail server whose web mail is behind this proxy, can block a single address for a while through the API (scope blocks:write); approvers can do it on the Blocked IPs page. jt-waf-mgr writes the list to one nginx file of deny lines, which covers every site, also those without ModSecurity. To use it:

  1. Create the file and include it once inside http { } in nginx.conf, then test and reload:

    sudo install -D -m 644 /dev/null /etc/nginx/jt-waf-mgr/blocked-ips.conf
    # in nginx.conf, inside http { }:   include /etc/nginx/jt-waf-mgr/blocked-ips.conf;
    sudo nginx -t && sudo systemctl reload nginx
    
  2. Settings → Temporary IP blocks: switch it on, and list the networks that must never be blocked (for example a CDN in front of your sites).

  3. Admin → API tokens: a token with blocks:write (and blocks:read), limited to the calling host's address.

  4. Example: a fail2ban action that blocks and unblocks through the API:

    # /etc/fail2ban/action.d/jt-waf-block.conf  (chmod 600: it holds the token)
    [Definition]
    actionban   = curl -fsS -m 10 -X POST -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
                  -d '{"ip": "<ip>", "ttl": <bantime>, "source": "<source>", "reason": "fail2ban <name>"}' <waf>/api/v1/blocks
    actionunban = curl -fsS -m 10 -X DELETE -H "Authorization: Bearer <token>" "<waf>/api/v1/blocks/<ip>?source=<source>"
    [Init]
    waf    = https://waf.example.com
    token  = jwm_...
    source = mail1/<name>
    

    A jail then uses action = jt-waf-block. Keep bantime between 60 seconds and 7 days (a longer or permanent ban is refused), and keep the jail's own ignoreip for internal addresses: they are refused anyway.

    Optionally, Settings → Temporary IP blocks → "Block sources that guess secret files automatically": an outside address asking for 5 different secret or configuration file names within an hour is blocked for 24 hours by a program rule. It reads the WAF events, counts only names that were refused or not found (4xx/5xx), needs at least one unmistakable name (.env, .git, keys, dumps, backups) and leaves an address that got a 2xx/3xx for any such name to a person. It skips the change workflow and blocks on every site, so it is off by default.

Blocks last 24 hours by default, at most 7 days from a token and 30 days by hand; an approver can extend one and an admin can make one permanent in the web interface (with a reason; never from a token or a rule). Internal networks, known scanners, trusted proxies and the protected list are never blocked. nginx checks the address after real_ip, so sites behind a CDN need set_real_ip_from / real_ip_header. Servers and locations with allow / deny lines of their own do not inherit the list; the Blocked IPs page lists them. A block takes effect for new requests within about a minute; connections already open (WebSocket) last until they close. Details: the API manual, section 4.9.

Country blocks (optional)

Limit one site by where requests come from: only the countries you list ("only Taiwan and Japan"), or every country except them. Each limit is a ModSecurity rule that goes through the change workflow like any other (checks, sandbox, approval, rollback); the address lists are data and are refreshed without it.

  1. Settings → Country blocks: switch on, then "Update now". A separate, sandboxed job downloads the five registries' delegated files (APNIC, ARIN, RIPE NCC, LACNIC, AFRINIC; about 28 MB together), checks each against the registry's MD5 file and against its own record counts, and only when all five pass replaces the lists. After that it runs once a day. The web service itself never connects to the internet.
  2. Changes → New → Country block: the site, "only these countries" or "block these countries", the countries. The checks count, from the access logs, how many requests and addresses the rule would have refused and how many of those were answered 2xx/3xx (real users it would shut out); the sandbox tests a request from an allowed and from a refused country and one from inside.
  3. After approval the root apply program writes the list the rule reads (/etc/nginx/modsec/jt-waf-mgr/countries/), tests nginx and reloads.

Never refused: the internal networks, the known scanners, the trusted proxies and the protected list (Settings → Temporary IP blocks), so a CDN in front of a site is not shut out. Behind a CDN the site needs set_real_ip_from / real_ip_header. The rules run in ModSecurity, so locations with modsecurity off are not covered. Registry data says where an address block was registered, not where its user is (a VPN, a cloud region or a roaming phone can be elsewhere).

Accounts and recovery

On the host, as root:

sudo jt-waf-mgr user list                       # accounts, roles and state (disabled, totp, must-change)
sudo jt-waf-mgr user add alice --role approver  # roles: viewer (default), operator, approver, admin
sudo jt-waf-mgr user unlock alice
sudo jt-waf-mgr user reset alice
sudo jt-waf-mgr user passwd alice
sudo jt-waf-mgr user disable alice              # and: enable
  • add prints a temporary password, which must be changed at the first sign-in.
  • unlock clears the failed sign-in lock.
  • reset gives a new temporary password, clears TOTP and forces a change at sign-in: the recovery for a lost phone.
  • passwd sets a password interactively.
  • disable / enable switch an account off and on again.
  • Every one of these changes is written to the audit trail.

Administration from the command line

What the web interface does for IP blocks, alerts, changes, settings, API tokens and threat intelligence is also a command, with the same rules. A write names the person it is done for (--as, an existing account with the role the web interface asks for); the audit trail records that person with cli as the source.

sudo jt-waf-mgr blocks list
sudo jt-waf-mgr blocks add 203.0.113.7 --reason "probing" --ttl 24h --as alice
sudo jt-waf-mgr blocks extend 12 --ttl 7d --reason "still probing" --as alice     # or --permanent (admin)
sudo jt-waf-mgr blocks remove 12 --note "false alarm" --as alice
sudo jt-waf-mgr alerts list ; sudo jt-waf-mgr alerts handle 23 --note "checked" --as alice
sudo jt-waf-mgr changes list --state pending_approval
sudo jt-waf-mgr changes approve 41 --as alice            # not one's own; --totp where the web asks for a code
sudo jt-waf-mgr changes regenerate --as alice            # rules an older version wrote: propose them written again
sudo jt-waf-mgr settings show review.
sudo jt-waf-mgr settings set review.keep_days=60 --as admin1
sudo jt-waf-mgr settings export -o settings.json         # --secrets --as admin1: keys and passwords too
sudo jt-waf-mgr settings import settings.json --only notify,workflow --dry-run
sudo jt-waf-mgr tokens list ; sudo jt-waf-mgr intel threats ; sudo jt-waf-mgr review run --as alice

Add --json for machine-readable output. In the web interface: Settings > Export and import settings (import shows the file next to the current values and writes only what you tick).

Upgrade

cd /opt/jt-waf-mgr-install   # the new release, unpacked into the same current
V=0.5.55; B=https://github.com/jasoncheng7115/jt-waf-mgr/releases/download/v$V
for f in jt-waf-mgr-$V.tar.gz jt-waf-mgr-$V.tar.gz.sig; do sudo curl -fsSLO $B/$f; done
sudo rm -rf current && sudo mkdir current && sudo tar xzf jt-waf-mgr-$V.tar.gz -C current --strip-components=1 && cd current
sudo ./upgrade.sh --check     # every check, nothing changed
sudo ./upgrade.sh             # backup, switch, checks; rolls back by itself on any failure
sudo ./upgrade.sh --rollback  # later, if needed: back to the version (and database) before the upgrade
sudo jt-waf-mgr doctor        # health summary at any time

The upgrade verifies the new release with the installed program and the pinned key, refuses while a change is being applied, keeps a backup in /var/backups/jt-waf-mgr/ and records every upgrade (and every rollback) in the audit trail.

Uninstall

cd /opt/jt-waf-mgr-install/current   # the fixed directory (the installed version)
sudo ./uninstall.sh           # remove the service and the program; keep data and configuration
sudo ./uninstall.sh --purge   # also remove /var/lib/jt-waf-mgr, /etc/jt-waf-mgr and the jtwaf user

The nginx configuration is never touched: remove the management vhost yourself. If the rule files were adopted, the managed files in /etc/nginx/modsec/jt-waf-mgr/ stay in place and nginx keeps loading them; maintain them by hand from then on.

Event analysis: which LLM

The analysis always runs on your own, self-hosted LLM server.

  • Server: OpenAI-compatible (llama.cpp server, vLLM, Ollama) with JSON-schema-constrained answers. Without them, plain JSON mode is used and answers are less reliable.
  • Model: an instruction model of about 14B parameters or more, at 4-bit quantization or better; 27–32B dense or a 30B-class MoE is recommended. Versions: Qwen 3.8 or later, Gemma 4 or later (older versions are not recommended).
  • Context window: at least 16k tokens. Measured: one batch of 11 candidates used about 3k input and 3.5k output tokens and took about 85 seconds on the production server.
  • Smaller models (8B and below) or 2–3-bit quantizations contradict themselves more between runs: in production a 3-bit-quantized model called the same probe an attack twice and a false positive once. jt-waf-mgr counters this with program-side rules for scanner patterns and a verdict history, but a stronger model helps.
  • Slow hardware: raise the LLM timeout in Settings (up to 900 s).

The AI may be wrong. Automatic application only ever tightens (allow → block); loosening always needs a person.

Integrations

  • Wazuh: a decoder and rules for jt-waf-mgr's own records are in deploy/wazuh (send the audit trail and events by syslog); an active response can call the IP block API.
  • jt-wazuh-mgr (a separate Jason Tools project that manages Wazuh) proposes WAF changes and temporary blocks with its own API token; it never approves.
  • Graylog: Settings → log destinations → format GELF over UDP, TCP or TLS to a GELF input; site, rule, outcome, source and country arrive as separate fields. A Graylog content pack is included (deploy/graylog/, Graylog 6.3 or later; instructions in Traditional Chinese): three streams, a pipeline that splits rule IDs and attack types, overview / alerts / audit dashboards and five event definitions (no notifications).
  • Other SIEM: up to 8 syslog destinations, each with its own protocol, format (JSON, CEF, LEEF, GELF, key=value, RFC 3164 / 5424) and content (audit trail, events, alerts).
  • fail2ban: the IP blocks page shows a ready action that blocks and unblocks through the API.
  • Messaging apps and webhooks: e-mail, Telegram, Teams, Slack, Discord, Zulip, Nextcloud Talk, an HMAC-signed webhook.

API for integrations

A SIEM, a SOAR playbook or a script connects with an API token (created by an admin, with scopes and allowed source addresses; a token can propose changes, never approve them). See the API manual.

Security (OWASP Top 10:2025)

See SECURITY.md and docs/COMPLIANCE.md. Please report vulnerabilities privately.

  • The web service listens on loopback, runs unprivileged and never connects out; only the apply program runs as root. It re-validates every request (allowed directives only, checksums, no manual edits on disk) and writes only the managed files. GeoIP downloads, the LLM analysis and notifications each run in their own sandboxed one-shot unit.
  • Strict CSP without unsafe-inline; everything that comes from a request (URLs, user agents, matched data, the model's text) is rendered as text.
  • Sensitive values are masked before they reach the database; secrets in settings are write-only.
  • A01: roles viewer / operator / approver / admin, API token scopes and source networks; tokens never approve.
  • A04 / A07: scrypt, TOTP with replay protection, lockout, one-time codes for sensitive actions (limited attempts).
  • A08: signed release manifest checked by the installer, the service and the apply program; hash-chained audit trail.
  • A09: every write is audited, also to syslog (one JSON line, control characters escaped).
  • Every release passes a test plan (TEST_PLAN.md): unit tests, a browser test of every page, a security scan of every route, an OWASP ZAP active scan, an independent review, upgrade and rollback tests.

Stack

Layer Choice
Backend Python 3.11+ standard library (http.server, sqlite3, hashlib.scrypt, tomllib, urllib, smtplib)
Database SQLite (WAL), append-only audit table with triggers
Frontend Vue 3 · Vite · own i18n (no runtime compilation, CSP-friendly) · Iconoir icons
WAF nginx · libmodsecurity v3 · ModSecurity-nginx · OWASP CRS 4
Deploy systemd units (service, apply, GeoIP, analysis, notifications); no Docker needed

Project layout

jt-waf-mgr/
├── jtwafmgr/            # the program (collector, web API, change workflow, apply, analysis, notifications, integrity)
│   ├── collector/       # ModSecurity audit log reader
│   ├── web/             # HTTP server, routes
│   └── static/          # the built web interface
├── frontend/            # Vue 3 source of the web interface
├── deploy/              # systemd units, nginx example, release key, Wazuh rule drafts, ZAP baseline
├── docs/                # spec, API contracts, compliance mapping, project site
├── tests/               # unit and integration tests (synthetic data only)
├── tools/               # build, release, preflight, browser test, security scan, ZAP scan
├── install.sh · upgrade.sh · uninstall.sh
└── TEST_PLAN.md · TEST_CHECKLIST.md · SECURITY.md · CHANGELOG.md

License

AGPL-3.0. If you run a modified version as a network service, offer its source to its users (the footer link does that for the unmodified version).

Disclaimer

  • jt-waf-mgr is provided "as is", without warranty of any kind, express or implied (see sections 15 and 16 of the AGPL-3.0). The authors and contributors are not liable for any damage or loss from using it.
  • A WAF lowers risk; it cannot stop every attack and can block legitimate users. Try it in a test environment before production, and start in log-only mode.
  • Event analysis and threat intelligence are helped by AI models and can be wrong. Their findings are suggestions: loosening changes always need a person's approval; look at the evidence before approving.
  • The administrators are responsible for the rules and for the nginx and ModSecurity configuration: keep backups, and make sure changes follow your organisation's policies and the law.
  • nginx, ModSecurity, OWASP CRS, MaxMind and GeoLite2 are trademarks of their owners; this project is not affiliated with them.

Explorer des projets similaires

Chargement…