Chapter 9 — Configuration Reference
The complete option-by-option reference (keys, values, defaults, scopes and
examples) is docs/options-reference.md; this
chapter is the full quick lookup, kept in sync with the parsers.
9.1 File layout and format
| File | Contents |
|---|---|
conf/wxserver.toml |
Main config: global, HTTP defaults, upstreams, stream, WAF, modules |
conf/manager.toml |
Console switch, listener, login protection, JWT, password hashes (0600) |
conf/acme.toml |
ACME policy and DNS credentials; 0600, master only |
conf/cert.toml |
Certificate index; sites reference it via ssl.cert |
conf/vhost/*.toml |
One file per site, aggregated by http.include |
conf/certs/ |
Certificates and private keys |
conf/mime.toml, conf/*_params.toml, conf/waf/ |
Auxiliary files (MIME table, parameter templates, WAF rules/cache) |
includehas two scopes: top-levelincludepulls whole fragments (may carryhttp/modules);http = { include = [...] }aggregates site fragments (fragments writeservers/upstreams/map/geo/split_clientsat the root). Relative paths resolve against each including file; only relative.tomlpaths inside the configuration directory are allowed (absolute paths,..and symlink escapes are rejected).manager.toml/acme.tomlare private: amanager/acmetop-level block in the main config or any include is an error (eveninclude = ["*.toml"]).- Saved configs use TOML 1.1 JSON-style multiline inline tables; TOML 1.0-only
validators may report false errors — trust
wxserver -t. - Validate with
wxserver -t -c <config>; hot-reload with-s reloadorPOST /api/config/reload.
9.2 global block
| Key | Type / values | Default | Description |
|---|---|---|---|
user / group |
string | platform default | Worker account; root refused (debug: WXSERVER_ALLOW_ROOT=1) |
worker_processes |
int / "auto" |
1 |
Worker count |
worker_cpu_affinity |
"auto" / CPU ids / cpumask |
unbound | Per-worker CPU affinity (Linux) |
log_cpu_affinity |
CPU ids | unbound | Master log thread affinity (Linux) |
pid |
path | run/wxserver.pid |
PID file |
shared_state |
path | run/wxserver.shm (enabled by default) |
Shared-state file (mmap, including the upstream DNS cache); empty string falls back to per-process state; default-path failure warns and falls back |
shared_state_size |
size | 32m |
Shared-state file size (when enabled) |
log_socket |
path | run/wxserver-log.sock |
Multi-worker log IPC socket |
log_queue_size |
lines; 0 = sync |
1024 with access log, else 64 |
Log queue length; ~320B per slot; fixed at startup |
log_flush_interval_ms |
ms | 200 |
Max flush interval; producers block instead of dropping |
server_tokens |
bool | true |
false hides the version (legacy "on"/"off" still accepted) |
graceful_timeout_sec |
seconds | 30 |
Graceful shutdown wait |
error_page_root |
directory | built-in pages directory | Lookup root/boundary for relative file: targets (server > http > global) |
log_redact / log_redact_keys |
bool / array | true / [] |
Access-log query redaction (password/token/secret/session/otp…) |
error_log |
log object | no output when path unset |
Error log; scope global/server/location, see §9.11 |
9.3 http block
| Key | Type / values | Default | Description |
|---|---|---|---|
include |
glob array | [] |
Aggregate site fragments |
client_max_body_size |
size; "0" unlimited |
10m |
Body limit; server/location override |
sendfile |
bool | true |
Static zero-copy; plain HTTP/1.1 static only |
static_meta_cache_ms |
ms | 0 |
Static stat cache TTL |
http2 / http3 |
bool | enabled | false is a hard off (wins over site-level true); actual enablement is decided by listen http2/http3 |
ktls |
bool | false |
Linux kTLS offload (AES-GCM), auto fallback |
max_header_bytes |
bytes | 1m |
Header limit (431) |
read_header_timeout_sec |
seconds | 30 |
Header read timeout |
idle_timeout_sec |
seconds | 75 |
Keep-alive idle timeout |
access_log |
path/object | not configured = no recording | Global access log; close with { enabled = false }, see §9.11 |
default_type |
MIME | — | Not consumed at runtime; use site/location level |
disabled_modules |
names | [] |
Globally disabled modules (merged with site lists) |
gzip |
object | off | Global gzip (see §9.10) |
error_page |
map | 404→file:4xx.html, 5xx→file:5xx.html |
Targets: file: / root: / link: (inheritance location > server > http) |
servers / upstreams / map / geo / split_clients / proxy_cache_path |
arrays | — | See §9.5–§9.7 |
proxy_cache_path fields: name (required), path (disk cache when set,
memory otherwise), max_size_mb (0 = unlimited), inactive_sec;
single-entry cache cap 16MB.
9.4 Derived variables (map / geo / split_clients)
| Key | Description |
|---|---|
map |
{ name = "$x", source = "$y", default, hostnames, entries }; keys: exact, ~regex, default; first match wins |
geo |
{ name = "$x", default, entries }; keys: CIDR / bare IP / default, longest prefix wins |
split_clients |
{ name = "$x", source = "$y", entries }; keys "N%", fnv hash of source |
9.5 server (site) block
| Key | Type / values | Default | Description |
|---|---|---|---|
name |
string | — | Only Manager/converter uses it to pick the file conf/vhost/{name}.toml; not stored in the site file — the file name is authoritative at load time |
domain |
array; exact/*.x/x.*/* |
[] |
"*" is the default site |
listen |
":80" or { addr, ssl, http2, http3 } |
required | Listeners and protocol switches |
root / index |
path / array | empty / ["index.html"] |
Site root and index files |
default_type |
MIME | — | Site-level MIME fallback |
locations |
array | — | Locations, see §9.6 |
ssl |
object | — | See §9.13 |
error_page |
{ "404" = "file:4xx.html" } |
inherits http level | Status → file:/root:/link: target |
error_page_root |
directory | inherits http/global | Site-level root for relative file: targets |
access_log |
path/object | inherits http | Site access log; close with { enabled = false } |
waf |
object | inherits global | Site WAF override |
http2 / http3 / ktls / sendfile / client_max_body_size |
bool / size | inherit http | Site-level overrides |
disabled_modules |
array | [] |
Site-disabled modules |
schedule |
object | off | Time windows: timezone (IANA), open[] (days/start/end), reason, status (400-599, default 503), page |
strict_sni_host |
bool | false |
Host must match SNI (else 421) |
https_redirect |
bool | false |
308 plaintext to https |
limit_rate / limit_rate_after |
size | unlimited | Site rate limit and free allowance |
disabled |
bool | false |
Temporarily offline |
rewrite |
array | [] |
rewrite rules; conditional via cond (§9.6) |
9.6 location block
path syntax: = /exact, /prefix/, ^~ /static/ (skip regex),
~ /, ~* / regex, @name (internal only). Priority: exact > longest prefix
(^~ skips regex) > regex in order > longest prefix.
| Key | Type / values | Default | Description |
|---|---|---|---|
type |
static/proxy/fastcgi/uwsgi/scgi/grpc/memcached/concat/image/nchan/upload/return/redirect/mp4/empty_gif/stub_status/external |
static |
Content handler |
root / alias |
path | inherit site | alias replaces the location prefix; DAV follows it too |
index / autoindex |
array / bool | ["index.html"] / false |
Index (internal redirect) / directory listing |
default_type / internal |
MIME / bool | — / false |
MIME override / internal-only access |
try_files |
array | [] |
Sequential probes; last item =code or internal URI; only $uri/ matches directories |
disable_symlinks |
bool | false |
Any symlink component under docroot → 403 |
return |
{ code, url | text } |
— | Status/redirect/text |
error_page / access_log |
as site level | inherit | Override |
client_max_body_size / limit_rate / limit_rate_after / sendfile |
as above | inherit | Location overrides |
waf |
object | inherit | Location WAF switch |
rewrite (server/location): unconditional rules use
[pattern, replacement, flag]; conditional rules use an object with cond.
cond is one table or an array (AND). Subjects: path with
exists/is_file/is_dir/is_exec booleans, or var with
eq/ne/matches/not_matches/truthy plus optional ignore_case.
Flags: last/break/redirect/permanent; flags = ["break"] rewrites and
stops further rewrite rules; a rule with break = true stops without changing
the URI. A replacement with ? drops the original query; http(s)://
targets redirect externally; more than 10 internal redirects → 500.
The old if block and conditional return/set/break were removed.
9.7 upstream
| Key | Type / values | Default | Description |
|---|---|---|---|
name |
string | required | Pool name; referenced as proxy_pass = "http://name" |
lb |
round_robin/least_conn/ip_hash |
round_robin |
Scheduler |
servers |
[{ addr, weight, max_fails, fail_timeout_sec, down }] |
required | weight default 0 (treated as 1) |
keepalive |
int | off | Idle connection pool |
health_check |
{ type=http|tcp, uri, interval_sec=5, timeout_sec=3, falls=2, rises=2, expected_min_status=200 } |
off | Active health check |
sticky |
{ cookie_name, path, expires_sec } |
off | Session persistence |
Runtime changes: POST/PATCH/DELETE /api/upstreams/<name>/servers…
(persist:true writes back).
9.8 stream and mail
stream (top-level, pure pass-through): upstreams[] (name/servers);
servers[]: listen (":port" or { addr, udp }), protocol (tcp/udp),
proxy_pass (pool/addr/$ssl_preread_server_name), return (mutually
exclusive with proxy_pass), ssl_preread (read SNI from ClientHello),
sni (domain → { proxy_pass } routing), proxy_connect_timeout_sec
(default 5). TLS termination / access logs / connection limits are not
implemented.
mail (top-level): servers[]: listen (required), proxy_pass
(required), proxy_protocol (default false, PROXY v1 to upstream),
timeout_sec (default 60, refreshed on I/O). name/protocol keys are
currently ignored (plain TCP pass-through); upstream failure closes the
connection.
9.9 waf block
| Key | Type / values | Default | Description |
|---|---|---|---|
enabled |
bool | false |
Site/location waf may override |
engine |
full/fast |
full |
full = SecRule/CRS engine; fast = lightweight signature checks (no rule compilation) |
rules |
[{ id, name, pattern, is_regex, caseless, targets, action, comment }] |
[] |
targets: URI/ARGS/HEADERS/BODY/COOKIE/UA/REFERER/IP; action: block/allow/log; allow short-circuits CRS |
response_rules |
array (block only) | [] |
Response body inspection; hit → 403 + X-WAF-Blocked |
response_body_limit |
bytes | 1m |
Response inspection buffer cap |
ip_lists (aliases ip_blacklist/ip_whitelist) |
{ white, black } |
empty | Whitelist allowed, blacklist 403 |
cc |
{ enabled, window_sec=60, max_requests=600, key=ip|ip+uri|ip+ua|$var, block_sec=60, log_interval_sec=30 } |
off | CC protection; log suppression window |
crs |
bool | false |
Load CRS: disk conf/waf/crs.toml first, else built-in crs-lite |
rules_files / rules_text |
TOML paths / SecRule text | — | Full CRS via wxserver-convert -from crs |
paranoia_level / inbound_anomaly_threshold / outbound_anomaly_threshold |
ints | 1 / 5 / 4 |
CRS tuning |
rule_exclusions |
id array | [] |
Exclude CRS rules by ID |
skip_unsupported_rules |
bool | false |
Skip unsupported directives |
Custom rules run before CRS; site rule IDs 1000000+, global 100000+.
@rx rules precompile into a shared DFA cache (conf/waf/cache/;
WXSERVER_WAF_CACHE=0 disables).
9.10 Module quick reference
Keys sit on the location (or http/server level) or under
modules.<name>; full semantics in docs/options-reference.md.
| Module | Main keys (defaults) | Notes |
|---|---|---|
| proxy | proxy_pass(req), proxy_set_header, proxy_hide_header, proxy_intercept_errors, proxy_redirect, proxy_next_upstream{http_codes,timeout}, proxy_next_upstream_tries, proxy_buffering_off, proxy_connect/read_timeout_sec(5⁄60), proxy_cache, proxy_cache_valid |
Reverse proxy; Upgrade+Connection enables WS tunnel; upstream failures 502⁄504 render the error page (error_page first, built-in 5xx fallback), details go to error.log; hostnames are resolved periodically by the master and re-fetched after worker connect failures |
| fastcgi | fastcgi_pass(req), fastcgi_param(s), fastcgi_params_file, fastcgi_index, fastcgi_split_path_info, fastcgi_hide_header, fastcgi_intercept_errors, fastcgi_keep_conn(false), fastcgi_keep_conn_max(1), fastcgi_keep_conn_idle_sec(15), fastcgi_*_timeout_sec(5/60/60), fastcgi_check_script(true) |
PHP; REQUEST_URI is always the original URI; keepalive is off by default so idle connections cannot exhaust PHP-FPM pm.max_children; fastcgi_pass hostnames are resolved by the master every 5 minutes and cached in shared_state (Unix sockets bypass DNS) |
| uwsgi/scgi | <p>_pass(req), <p>_param, <p>_params_file, <p>_connect/read_timeout_sec(5⁄60), modifier1(0) |
UWSGI/SCGI protocols; hostnames resolved and cached by the master |
| grpc | grpc_pass(req), grpc_tls, grpc_tls_server_name/ca/client_cert/client_key, grpc_*_timeout_sec(5⁄60), grpc_intercept_errors |
h2 pass-through; grpc-status via trailers; hostnames resolved and cached by the master (TLS SNI keeps the hostname) |
| memcached | memcached_pass(req), memcached_key($host$request_uri), memcached_content_type, timeouts(5⁄10) |
GET/HEAD only; miss → 404; hostnames resolved and cached by the master, Unix sockets unsupported |
| staticfile | root/alias/index/autoindex/try_files/disable_symlinks, gzip_static/brotli_static/zstd_static, dav{methods,create_full_put_path} |
WebDAV RFC 4918; precompressed br>zstd>gzip |
| rewrite | rewrite[[pat,repl,flag]], object + cond, set, return |
flag defaults to last |
| limit | limit_req{rate,burst=0,key,status=503}, limit_conn{limit,key,status=503} |
shared_state on by default; counters shared across workers out of the box |
| access | access{rules[{action,cidr}],default=deny} |
a configured level replaces the parent |
| auth_basic | auth_basic{realm,users_file,users} |
htpasswd compatible |
| auth_request | auth_request{url,method=GET,timeout_ms=3000,allow_codes=[200],deny_codes=[401,403],copy_headers} |
external auth subrequest |
| auth_jwt | auth_jwt{alg=HS256,secret,key_file,jwks_uri,leeway_sec=30,claims,realm} |
HS256/RS256/ES256 |
| secure_link | secure_link{secret,md5_arg,expires_arg,require=true} |
MD5(base64url) signed URLs |
| referer | referer{valid,invalid_status=403} |
anti-hotlink |
| realip | realip{from,header=X-Forwarded-For,mode=recursive} |
recursive skips trusted proxies right-to-left |
| userid / browser / geoip | userid{name,path,expires,domain}, browser{modern,ancient,deny_ancient}, geoip{db,on} |
vars $uid/$modern_browser/$geoip_* |
| headers | headers{expires,add_headers,add_headers_always,set_headers,more_set_headers,more_clear_headers,more_headers,clear_headers} |
add replaces at that level; more_* parents first |
| security_headers | security_headers{enabled,hsts,hsts_plaintext,csp,x_frame_options,referrer_policy,permissions_policy,nosniff} |
off by default; per-field merge |
| gzip/gunzip | gzip{on,level=6,min_length=20,types,vary=true,proxied=true,disable,no_compression_4xx}, gunzip{on} |
only 200/403/404 |
| brotli/zstd | brotli{on,level=5,min_length=256}, zstd{on,level=3,min_length=256} |
dynamic priority br>gzip>zstd |
| sub/addition/ssi/charset/minify | sub{patterns[{search,replace}],once,types}, addition{before,after,types}, ssi{on,types,limit=8m}, charset{charset,source_charset,override_charset,charset_types}, minify{on,types,max_size=256k} |
body processing |
| image_thumb | image_thumb{quality=75,cache,backend,types,default_mode,water{...},watermark_text} |
URL !c300x200.jpg |
| nchan | nchan{channel,mode=pubsub,buffer=16,history,max_subscribers=1024,max_message=256k,poll_timeout_sec=30,heartbeat_sec=15,cors} |
SSE/WS/long-poll |
| upload | upload{dir=run/uploads,max_size=1g,cors} |
tus 1.0 |
| mirror | mirror{targets,copy_body=false} |
async mirror |
| accesslog/logsink | access_log (object in §9.11), modules.http_logsink{protocol=udp,addr,url,format=json,timeout_ms=1000} |
remote log sink |
| error_guard | modules.http_error_guard{enabled,window_sec=60,threshold=20,block_sec=300,status=429,count_codes,count_5xx,key,whitelist} |
error-rate ban |
| sysguard | modules.http_sysguard{enabled,max_load1,min_mem_available_mb,status=503,retry_after=5} |
overload guard |
fastcgi passes
SCRIPT_FILENAME,QUERY_STRING,REQUEST_METHOD,HTTP_*,SERVER_ADDR,REMOTE_PORT,REDIRECT_STATUSand other variables to PHP by default. For HTTP/2 and HTTP/3 requests without aHostheader,HTTP_HOSTis filled from:authority; multipleCookieheaders are joined with"; "(otherwise PHP sees only the first cookie and WordPress logins and sessions break).
9.11 Log object (error_log / access_log)
| Field | Type / values | Default | Description |
|---|---|---|---|
path |
path with $year/$month/$day |
unset (no output) | relative to workdir; absolute log dir remaps logs/; off/- rejected, use enabled = false to disable |
level |
debug/info/warn/error | warn |
error_log only |
enabled |
bool | true |
false fully closes this layer of error_log/access_log (no file, stderr or sink); lower layers may re-enable; cross-platform replacement for /dev/null |
console |
bool | false |
error_log only: also writes stderr/journal; enabled = false wins |
max_size_mb / max_backups |
ints | 0 |
size rotation / kept copies |
encrypt / key_file |
bool / path | false |
AES-256-GCM per line (WXE1:); Manager decrypts on read |
format |
text/binary |
text |
binary = .wxlog (read with wxserver-log) |
format_template |
template | combined | text format only |
sample |
int | 1 |
one line per N requests |
9.12 manager.toml
| Key | Type / values | Default | Description |
|---|---|---|---|
enable |
bool | false |
Enable the console |
listen |
host:port | 127.0.0.1:9090 |
non-loopback requires [tls] or allow_http=true |
tls |
{ cert } from the cert store or { cert_file, key_file } |
— | Console TLS |
allow_cidr |
CIDR/bare IP array | [] |
Source whitelist by TCP peer; miss → 403 |
trust_proxy / proxy_cidr |
bool / CIDR array | false / [] |
trust_proxy requires non-empty proxy_cidr (fail closed); requests carrying X-Forwarded-*/Via/Forwarded are refused by default (403) |
domain |
hostnames | [] |
Host validation, mismatch → 421 |
allow_http |
bool | false |
Explicitly allow plaintext non-loopback |
users |
[{ name, password_hash }] |
first start creates admin |
bcrypt |
jwt |
{ secret_file=run/jwt.secret, expire_sec=86400 } |
— | Session tokens |
login |
{ max_fail, window_sec, block_sec, captcha_after, captcha_ttl } |
— | Login lockout and captcha |
totp |
system-maintained | — | 2FA state in run/manager-totp.json (0600); do not hand-edit |
9.13 acme.toml and ssl
[certs.<name>]: domains(required), email, challenge(auto/http/dns),
directory/staging, timeout_sec=60, auto_renew=true,
renew_before_days=30, check_interval_hours=12, key_type=ec256,
eab_kid/eab_hmac_key, must_staple, preferred_chain, on_demand,
request_timeout_sec=30(1-180), dns{provider=cloudflare|alidns|tencentcloud|route53,
credentials, api_base, ttl_sec=120, propagation_timeout_sec=120,
propagation_delay_sec, resolvers, proxy}.
Site ssl: cert (store name) or cert_file/key_file, protocols
(TLS1.2⁄1.3), ciphers, session_cache, client_cert_file/verify_client/
verify_depth (mTLS), prefer_server_ciphers.
9.14 Variables
Built-in: $uri $document_uri $request_uri $args $query_string $host
$server_name $http_host $http_<header> $scheme $https $server_port
$request_method $server_protocol $remote_addr $client_ip
$binary_remote_addr $remote_user $document_root $content_length
$content_type $is_args $internal_redirect, plus $arg_*, $cookie_*.
Module-registered: $jwt_claim_*/$jwt_error, $secure_link/
$secure_link_expires, $uid, $modern_browser/$ancient_browser,
$geoip_*, rewrite set and map/geo/split_clients derived variables.
Resolution order: built-in → modules → derived.
9.15 CLI and conversion
wxserver -c <config> # run in foreground
wxserver -t -c <config> # validate
wxserver -s reload|stop|quit # signal control
wxserver -no-manager # disable the console
wxserver --service install|uninstall|start|stop|restart|status
wxserver --reset-password [pwd] / --reset-totp
wxserver-convert -from auto|nginx|apache|htaccess|crs -in <file> [-out <file>] [--split-vhosts conf/vhost]
wxserver-tool htpasswd / bench / precompress / toml
wxserver-convert expands includes in file mode; --split-vhosts writes one
conf/vhost/{name}.toml per site; .htaccess is auto-detected and yields a
paste-ready location fragment; unsupported directives print warnings
(-quiet silences). Tool details: Chapter 7.