Skip to main content
Installation

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 -d

Most 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.

SettingDefaultDescription
RSTWAF_CONSOLE_BIND127.0.0.1Listen address. If you change it to an internal management address, open the port only to a controlled management network
RSTWAF_CONSOLE_PORT9443Listen port
RSTWAF_COOKIE_SECUREnot setSet to 1 when the console sits behind an HTTPS reverse proxy
RSTWAF_CONSOLE_TRUSTED_PROXIESnot setReverse 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

SettingDefaultDescription
RSTWAF_HTTP_PORT80Site HTTP port
RSTWAF_HTTPS_PORT443Site 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

SettingDefaultDescription
RSTWAF_ONLINE_FEATURESoffMaster 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_ENABLEDoffCrowdSec CTI IP reputation lookups; needs the master switch on
RSTWAF_LICENSE_SERVERnot setLicence 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

SettingDescription
RSTWAF_TZControl 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

SettingDefaultDescription
CRS_PL1Default 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_B64balancedDefault mode of each semantic detection module: off, observe, balanced or strict. Lenient mode can only be chosen per site in the console
RSTWAF_SEM_RESPONSEbalancedResponse-side detection. observe logs only
RSTWAF_ALLOWED_METHODSGET HEAD POST OPTIONS PUT PATCH DELETEHTTP methods allowed for sites without their own list
RSTWAF_ARGS_LIMIT5000Default parameter count limit
RSTWAF_PRESCREENonSkips 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.

SettingDefaultDescription
RSTWAF_OVERLOAD_ACTIONrejectreject: 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_INFLIGHTauto, max(1024, 512 × CPU)Concurrent request limit. Raise it for sites with slow back ends running at full load
RSTWAF_OVERLOAD_RETRY_AFTER5Seconds in the Retry-After header of a 503
RSTWAF_MAX_CONNSautoConnection limit per node
RSTWAF_MAX_CONNS_PER_IP0 (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_TIMEOUT10sTotal time allowed to read request headers, against slowloris
RSTWAF_READ_BODY_IDLE, RSTWAF_READ_BODY_MIN_RATE30s, 500Drop the connection after 30 seconds without progress on the body, or below an average of 500 B/s
RSTWAF_IDLE_TIMEOUT2mIdle 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

SettingDefaultDescription
RSTWAF_ACCESS_LOG_KEEP20Rotated 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_KEEP100, 5Rotation size and number of CRS audit log files kept
RSTWAF_EVENT_AGG_PER_KEY30Events recorded in full per IP, rule and minute; the rest are counted as aggregated. 0 turns aggregation off
RSTWAF_EVENT_RATE300Events stored individually per second across all nodes
RSTWAF_UPSTREAM_IDLE_CONNS128Idle connections kept per upstream. Lower it for origins with little concurrency
RSTWAF_CROWDSEC_ACQUISacquis.yamlBy 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

SettingDefaultDescription
RSTWAF_UPDATE_RUNNERonWith off, no systemd unit is installed; after confirming an upgrade in the console, run update-runner.sh run by hand
RSTWAF_UPDATE_URLvendor channelUpdate source pre-filled in the console, for example an internal mirror
RSTWAF_UPDATE_PROXYnot setHTTP(S) proxy used only for the update source
RSTWAF_UPDATE_CAnot setAdditional 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 variables RSTWAF_URL=http://127.0.0.1:9443 and RSTWAF_TOKEN_FILE=<token file>.
  • Remote Streamable HTTP: docker compose --project-directory /opt/rstwaf --profile mcp up -d. The endpoint is http://127.0.0.1:9100/mcp and the client sends Authorization: Bearer <token>. It listens on loopback only by default; put it behind a TLS reverse proxy to expose it.
SettingDefaultDescription
RSTWAF_MCP_BIND, RSTWAF_MCP_PORT127.0.0.1, 9100Listen address and port for remote MCP
RSTWAF_MCP_READ_ONLY0Set to 1 to hide the write tools

On this page