Configuration reference
Settings in the install directory's .env that operators can change, covering console access, the online switch, detection defaults, overload protection, log capacity, online updates and MCP.
install.sh writes the configuration to /opt/rstwaf/.env (mode 0600). The secrets in it are generated at random for each instance. After editing .env, run this in the install directory:
cd /opt/rstwaf && sudo docker compose up -dMost protection settings are made in the console and stored per site; they do not need .env. The detection settings in .env are global defaults, and a site's own settings take precedence.
RSTWAF_MASTER_KEY in .env encrypts the TOTP, alert-channel and threat-intelligence secrets stored in the database. If it is lost, those secrets must be entered again. Back up .env together with the data, and do not edit the secret settings by hand.
Console access
The console is plain HTTP and listens on 127.0.0.1:9443 by default.
| Setting | Default | Description |
|---|---|---|
RSTWAF_CONSOLE_BIND | 127.0.0.1 | Listen address. If you change it to an internal management address, open the port only to a controlled management network |
RSTWAF_CONSOLE_PORT | 9443 | Listen port |
RSTWAF_COOKIE_SECURE | not set | Set to 1 when the console sits behind an HTTPS reverse proxy |
RSTWAF_CONSOLE_TRUSTED_PROXIES | not set | Reverse proxies in front of the console, as comma-separated IPs or CIDRs, for example 172.16.0.0/12 |
The console reads X-Forwarded-For only from addresses in RSTWAF_CONSOLE_TRUSTED_PROXIES. Behind a reverse proxy without this setting, every user appears to come from the proxy, so the sign-in failure limit (5 attempts per IP in 15 minutes) and the console IP allow list can only act on the proxy's address.
Site ports
| Setting | Default | Description |
|---|---|---|
RSTWAF_HTTP_PORT | 80 | Site HTTP port |
RSTWAF_HTTPS_PORT | 443 | Site HTTPS port |
Only TCP 443 is published by default. For HTTP/3, also publish 443/udp and allow UDP on the load balancer.
Online switch
| Setting | Default | Description |
|---|---|---|
RSTWAF_ONLINE_FEATURES | off | Master switch for outbound connections. With off, only online updates and Feishu QR sign-in can reach the internet, and only when each is allowed separately in the console |
RSTWAF_CTI_ENABLED | off | CrowdSec CTI IP reputation lookups; needs the master switch on |
RSTWAF_LICENSE_SERVER | not set | Licence server for online activation; needs the master switch on |
For the destination and data sent by each outbound feature, see Requirements and network.
Time zone
| Setting | Description |
|---|---|
RSTWAF_TZ | Control plane time zone as an IANA name, for example Asia/Shanghai. Sets what "today" means and the day, week and month boundaries in reports |
Detection defaults
| Setting | Default | Description |
|---|---|---|
CRS_PL | 1 | Default OWASP CRS paranoia level |
RSTWAF_SEM_SQLI, RSTWAF_SEM_XSS, RSTWAF_SEM_RCE, RSTWAF_SEM_SSTI, RSTWAF_SEM_NOSQL, RSTWAF_SEM_XXE, RSTWAF_SEM_JNDI, RSTWAF_SEM_GRAPHQL, RSTWAF_SEM_B64 | balanced | Default mode of each semantic detection module: off, observe, balanced or strict. Lenient mode can only be chosen per site in the console |
RSTWAF_SEM_RESPONSE | balanced | Response-side detection. observe logs only |
RSTWAF_ALLOWED_METHODS | GET HEAD POST OPTIONS PUT PATCH DELETE | HTTP methods allowed for sites without their own list |
RSTWAF_ARGS_LIMIT | 5000 | Default parameter count limit |
RSTWAF_PRESCREEN | on | Skips CRS rules that cannot match, to save CPU. Detection results are unchanged |
Overload protection
Defaults are calculated from each node's CPU and memory. Change them only after a load test.
| Setting | Default | Description |
|---|---|---|
RSTWAF_OVERLOAD_ACTION | reject | reject: return 503 with Retry-After when overloaded. bypass: forward the excess requests without CRS or semantic inspection, with a critical alert each time overload begins |
RSTWAF_OVERLOAD_MAX_INFLIGHT | auto, max(1024, 512 × CPU) | Concurrent request limit. Raise it for sites with slow back ends running at full load |
RSTWAF_OVERLOAD_RETRY_AFTER | 5 | Seconds in the Retry-After header of a 503 |
RSTWAF_MAX_CONNS | auto | Connection limit per node |
RSTWAF_MAX_CONNS_PER_IP | 0 (off) | Connection limit per IP. Harms legitimate users behind load balancers or NAT; 256 is a reasonable value when clients connect directly or through PROXY protocol |
RSTWAF_READ_HEADER_TIMEOUT | 10s | Total time allowed to read request headers, against slowloris |
RSTWAF_READ_BODY_IDLE, RSTWAF_READ_BODY_MIN_RATE | 30s, 500 | Drop the connection after 30 seconds without progress on the body, or below an average of 500 B/s |
RSTWAF_IDLE_TIMEOUT | 2m | Idle keep-alive timeout |
In bypass mode, CrowdSec bans, IP lists, access rules, rate limits, challenges and the waiting room still apply, and memory pressure still returns 503. Use it only when availability matters more than inspection and other protection is in place.
Logs and capacity
| Setting | Default | Description |
|---|---|---|
RSTWAF_ACCESS_LOG_KEEP | 20 | Rotated access-log files kept per node, about 0.4 GiB. This sets how long a node can buffer logs while the control plane is unreachable: about 28 minutes at 1k RPS, about 3 minutes at 10k RPS |
RSTWAF_AUDIT_LOG_ROLL_MB, RSTWAF_AUDIT_LOG_KEEP | 100, 5 | Rotation size and number of CRS audit log files kept |
RSTWAF_EVENT_AGG_PER_KEY | 30 | Events recorded in full per IP, rule and minute; the rest are counted as aggregated. 0 turns aggregation off |
RSTWAF_EVENT_RATE | 300 | Events stored individually per second across all nodes |
RSTWAF_UPSTREAM_IDLE_CONNS | 128 | Idle connections kept per upstream. Lower it for origins with little concurrency |
RSTWAF_CROWDSEC_ACQUIS | acquis.yaml | By default only 4xx, 5xx and blocked access-log lines go to CrowdSec. acquis-all.yaml sends every line, at a higher CPU cost |
Online updates
| Setting | Default | Description |
|---|---|---|
RSTWAF_UPDATE_RUNNER | on | With off, no systemd unit is installed; after confirming an upgrade in the console, run update-runner.sh run by hand |
RSTWAF_UPDATE_URL | vendor channel | Update source pre-filled in the console, for example an internal mirror |
RSTWAF_UPDATE_PROXY | not set | HTTP(S) proxy used only for the update source |
RSTWAF_UPDATE_CA | not set | Additional PEM CA trusted for the update source |
MCP
The package includes an MCP server that lets AI assistants query events and statistics and apply bans or allow rules through the open API. Write actions need confirmation and are marked as coming through MCP in the audit log. The MCP server does not start by default.
First issue a token for the assistant's account under Settings > Open API, then choose one of:
- Local stdio:
/opt/rstwaf/bin/rstwaf-mcp, connecting to the console through the environment variablesRSTWAF_URL=http://127.0.0.1:9443andRSTWAF_TOKEN_FILE=<token file>. - Remote Streamable HTTP:
docker compose --project-directory /opt/rstwaf --profile mcp up -d. The endpoint ishttp://127.0.0.1:9100/mcpand the client sendsAuthorization: Bearer <token>. It listens on loopback only by default; put it behind a TLS reverse proxy to expose it.
| Setting | Default | Description |
|---|---|---|
RSTWAF_MCP_BIND, RSTWAF_MCP_PORT | 127.0.0.1, 9100 | Listen address and port for remote MCP |
RSTWAF_MCP_READ_ONLY | 0 | Set to 1 to hide the write tools |
Installation
Verify and install the offline package, installer options and optional components, first sign-in, and uninstalling.
Multi-node and high availability
Manage several data plane nodes from one control plane. Enable node access, create credentials and join tokens, install nodes, run the data plane active/active behind health checks, share counters, and use mirror inspection nodes.