Configuration file
Complete reference for HostWall's YAML configuration file: every key, its type, default and notes.
HostWall works without a config file: the defaults are safe, and you can add sites in the dashboard or with the CLI. Use a YAML file when you want settings as code, or to change server-wide settings such as ports, trusted proxies or the HTTPS email.
- Where the file lives and how changes apply
server: listeners, dashboard, data, trusted proxies, limitstls: automatic HTTPSdefaults: values for sites that don't set their ownsites: the websites and APIs you protect- Modes, paranoia levels, fail open or closed, security header presets, trusted proxies
- File sites and dashboard sites
- Full example
Where the file lives
| OS | Default path |
|---|---|
| Linux | /etc/hostwall/hostwall.yaml |
| macOS | /usr/local/etc/hostwall/hostwall.yaml |
| Windows | C:\ProgramData\hostwall\hostwall.yaml |
Change it with --config <file> or the HOSTWALL_CONFIG environment variable. A missing file is not an error: HostWall uses the defaults.
Unknown keys are rejected. A typo such as upstrem: fails loudly instead of silently weakening protection. Check the file before applying it:
sudo hostwall validateHow changes apply
HostWall watches the config file. When the file changes, the running server reloads it within about 2 seconds, with no downtime. sudo hostwall reload asks for a reload explicitly (it also picks up dashboard sites changed by the CLI).
If the new configuration is invalid, the running configuration stays in place. The error is written to the log (reload failed; keeping the previous configuration) and shown on the dashboard's Overview page.
Some settings are only read at startup. Restart HostWall (sudo systemctl restart hostwall) after changing:
server.http,server.https,server.dashboard,server.dashboard_tls,server.metrics(the log warns:listener settings changed; restart hostwall to apply them)server.data_dir(a reload with a different data directory is refused)- everything under
tls
Value types
| Type | Format |
|---|---|
| address | host:port. ":80" means every interface; "127.0.0.1:9443" means localhost only. Quote it in YAML. |
| size | A number of bytes, or a number with B, KB, MB or GB (1 KB = 1024 bytes). For example 512KB, 1MB. |
| upstream | localhost:3000, http://10.0.0.5:8080 or https://app.internal. No scheme means http. No query, fragment or credentials. |
Tip: quote values like "off" and "on". Some YAML tools treat them as booleans.
server
server:
http: ":80"
https: ":443"
dashboard: "127.0.0.1:9443"
dashboard_tls: true
metrics: ""
data_dir: /var/lib/hostwall
trusted_proxies: []
body_inspect_limit: 1MB
event_retention_days: 30| Key | Type | Default | Notes |
|---|---|---|---|
http | address or "off" | ":80" | Plain HTTP listener. Redirects HTTPS sites to https:// and answers Let's Encrypt HTTP challenges. Restart to apply. |
https | address or "off" | ":443" | HTTPS listener with automatic certificates. "off" disables HTTPS for every site. Restart to apply. |
dashboard | address or "off" | "127.0.0.1:9443", or HOSTWALL_DASHBOARD if set | Dashboard and its JSON API. See Dashboard access. Restart to apply. |
dashboard_tls | bool | true | Serve the dashboard over HTTPS with a self-signed certificate (created in the data directory, valid 5 years, renewed automatically). Set false only for local testing: session cookies are then sent without the Secure flag. Restart to apply. |
metrics | address | "" (off) | Prometheus endpoint at /metrics, for example "127.0.0.1:9180". No authentication: keep it on localhost or a private network. Restart to apply. |
data_dir | path | /var/lib/hostwall (Linux) | Database, certificates and the initial admin password file. The systemd service passes --data /var/lib/hostwall, which overrides this key. Restart to apply. |
trusted_proxies | list | [] | Proxies and CDNs allowed to tell HostWall the real client IP. CIDRs, single IPs, private or cloudflare. See Trusted proxies. |
body_inspect_limit | size | 1MB | How much of each request body the WAF inspects. See Body inspection limit. |
event_retention_days | integer | 30 | Security events older than this are deleted (checked every hour). Use a positive number; 0 means the default. Per-minute traffic statistics are kept for 90 days. |
request_log | bool | true | Record every request (clean or not) for the dashboard's Requests page. See Request log. Can be changed in Settings. |
request_log_days | integer | 3 | How long the request log is kept, 1 to 90 days. |
Dashboard access
By default the dashboard listens on 127.0.0.1:9443, so it can't be reached from the internet. Use an SSH tunnel from your computer:
ssh -L 9443:127.0.0.1:9443 you@your-server
# then open https://localhost:9443To reach it directly, listen on all interfaces and restart:
server:
dashboard: "0.0.0.0:9443"If you do this, limit who can connect with your firewall (for example sudo ufw allow from 203.0.113.7 to any port 9443). Turn on two-factor sign-in first (Settings). Sign-in is limited to 5 failed attempts per 15 minutes, but the fewer people who can reach it, the better. The certificate is self-signed, so browsers show a warning.
In Docker, the image already makes the dashboard listen on 0.0.0.0:9443 inside the container (through HOSTWALL_DASHBOARD). Publish it as -p 127.0.0.1:9443:9443 and use a tunnel. See Install: Docker.
"off" disables the dashboard entirely. You can still manage sites with the CLI and the config file.
Request log
With request_log: true (the default), HostWall records one line per request: time, site, client IP, method, host, path and query, status, response size, total and inspection time, result (allowed, blocked, would block, error), user agent and referer. Bodies and other headers are never stored. Secret values in query strings (such as token= or password=) are redacted.
Entries are written in batches in the background, so logging never slows down traffic: if the disk can't keep up, entries are dropped and a warning is logged. Entries older than request_log_days are deleted every hour, and at most 1,000,000 entries are kept, so a busy site can't fill the disk. As a rough guide, each entry takes 200 to 400 bytes.
Turn the log off for one site with its log_requests option, or for every site with request_log: false. Attacks are always recorded on the Attacks page either way. The Settings page can change both global values; a value set there takes precedence over the file until you click Use config file.
Body inspection limit
body_inspect_limit sets how many bytes of a request body the WAF reads. Requests with larger bodies are not rejected: HostWall inspects the first part and forwards the whole body to your app. There is no maximum upload size in HostWall itself.
- Raise it (for example
8MB) if attacks could hide deep inside large form posts or JSON. - Lower it if you handle many large uploads and want to save memory and CPU.
Bodies up to 1 MB are inspected in memory. A body that is cut off by the limit isn't treated as malformed, so a large JSON upload won't be blocked just for being truncated.
Prometheus metrics
When metrics is set, GET /metrics returns:
| Metric | Type | Labels |
|---|---|---|
hostwall_build_info | gauge | version |
hostwall_requests_total | counter | site, result |
hostwall_upstream_errors_total | counter | site |
hostwall_waf_seconds | summary (_sum, _count) | site |
tls
Automatic HTTPS with Let's Encrypt, using the HTTP challenge on port 80. Certificates are stored in <data_dir>/certs and renewed automatically. All tls settings are read at startup: restart after changing them.
tls:
email: admin@example.com
staging: false
ca: ""| Key | Type | Default | Notes |
|---|---|---|---|
email | string | "" | Your email for the ACME account. Let's Encrypt may use it for important account notices. Optional but recommended. |
staging | bool | false | Use the Let's Encrypt staging server. Its certificates aren't trusted by browsers, but its rate limits are much higher. Use it while testing a new setup, then set it back to false and restart. |
ca | URL | "" | A custom ACME directory URL, for another ACME CA (for example a private step-ca). Overrides staging. |
A site gets a certificate when all of these are true:
server.httpsisn't"off";- the site's
tlsisauto(the default); - the hostname is a public name: it contains a dot, isn't an IP address or wildcard, and doesn't end in
.localhost,.local,.test,.internal,.lan,.home.arpa,.example,.invalid,.intranetor.corp.
Sites that don't meet these conditions are served over plain HTTP, without a redirect.
Wildcard certificates and the DNS challenge are planned for v0.2.
defaults
Values used by every site that doesn't set its own.
defaults:
mode: monitor
paranoia: 1
fail: open
headers: basic
compress: true| Key | Values | Default | Notes |
|---|---|---|---|
mode | monitor, block, off | monitor | See Modes. |
paranoia | 1 to 4 | 1 | See Paranoia levels. |
fail | open, closed | open | See Fail open or closed. |
headers | basic, strict, off | basic | See Security header presets. |
compress | bool | true | gzip-compress responses. See Compression. |
Write these values in lowercase: open, not Open.
sites
A list of sites. Each site is one website or API, reached by one or more hostnames.
sites:
- domain: example.com
aliases: [www.example.com]
upstream: http://localhost:3000
mode: block
paranoia: 1
fail: open
tls: auto
headers: basic
compress: true| Key | Type | Default | Notes |
|---|---|---|---|
domain | hostname | required | The site's main hostname. Lowercased; a trailing dot is removed. Each hostname can belong to only one site. |
aliases | list of hostnames | [] | More hostnames for the same site, such as www.example.com. Each gets its own certificate. |
upstream | upstream, or a list | required | Where your app listens. With several upstreams, requests are spread across them in turn (round-robin). There are no health checks yet. |
mode | monitor, block, off | defaults.mode | See Modes. |
paranoia | 1 to 4 | defaults.paranoia | See Paranoia levels. |
fail | open, closed | defaults.fail | See Fail open or closed. |
tls | auto, off | auto | auto: get a certificate and redirect HTTP to HTTPS. off: plain HTTP only, for example behind another proxy that handles TLS. |
headers | basic, strict, off | defaults.headers | See Security header presets. |
compress | bool | defaults.compress | See Compression. |
skip_paths | list of paths | [] | Paths passed to your app without inspection, such as a health check or a webhook from a service you trust. A path matches itself and everything below it: /healthz matches /healthz and /healthz/deep but not /healthzX. The request path is normalised first, so /healthz/../admin is still inspected. At most 50 paths; / isn't allowed (use mode: off). |
inspect_static | bool | false | Also inspect static files. By default, simple GET and HEAD requests for files such as .css, .js, .png or .woff2, with no query string and no body, skip the WAF to save CPU. Turn this on if your app generates responses under such extensions. |
log_requests | bool | true | Record this site's requests in the request log. |
Notes:
- A site's
domaincan be an IP address. It is then served over plain HTTP. - Requests for a hostname that no site uses get a
404"Site not found" page. That includes requests to the server's bare IP address. - Wildcard hostnames such as
*.example.compass validation but don't match any requests yet. List each hostname inaliasesinstead. - An
https://upstream must have a certificate that is valid for its hostname. Self-signed upstream certificates aren't supported yet; usehttp://on a private network or localhost.
What HostWall sends to your app
HostWall forwards the request with the original Host header and sets:
| Header | Value |
|---|---|
X-Forwarded-For | The real client IP (replaces any value the client sent) |
X-Real-IP | The real client IP |
X-Forwarded-Proto | https or http, as the request reached HostWall |
X-Forwarded-Host | The original Host |
X-Request-Id | A random ID for this request. It is shown on block pages and in events. |
Configure your app to trust these headers from HostWall's address (often 127.0.0.1) so it logs real client IPs.
Compression
With compress: true (the default), HostWall gzip-compresses responses when:
- the client sends
Accept-Encoding: gzip; - your app didn't compress the response already;
- the content is text-like (
text/*, JSON, JavaScript, XML, SVG, WebAssembly and some fonts); - the body is at least 1 KB;
- it isn't a
HEAD,204,206or304response, or a server-sent event stream (text/event-stream); - the response doesn't carry
Cache-Control: no-transform.
Compressed responses get Vary: Accept-Encoding, and a strong ETag becomes a weak one (W/"...") because the bytes are no longer identical.
Set compress: false for a site whose app already compresses everything, or if you need byte-identical responses.
Modes
| Mode | What happens |
|---|---|
monitor | Every request is inspected. Attacks are logged but allowed through. In the dashboard they show as "Would block". |
block | Every request is inspected. Attacks are stopped with a 403 "Request blocked" page (or a JSON error if the client asked for JSON). |
off | No inspection. HostWall is only a reverse proxy with HTTPS. |
New sites start in monitor mode. Leave a site in monitor mode for a few days of normal traffic, check the Attacks page for false alarms, then switch to block. See Handling false alarms.
Paranoia levels
HostWall uses the OWASP Core Rule Set (CRS) v4. The paranoia level decides how many of its rules are active. Higher levels catch more unusual attacks but also flag more normal traffic.
| Level | What changes | Good for |
|---|---|---|
| 1 (default) | Core rules with very few false positives: clear SQL injection, XSS, command injection, path traversal, known scanners and protocol abuse. | Almost every site. Start here. |
| 2 | Adds rules for more obfuscated attacks and more SQL and XSS patterns. Expect some false alarms on rich text, search boxes and APIs. | Sites holding sensitive data, after a monitor period. |
| 3 | Adds stricter checks, for example on special characters and lengths in parameters. Needs exceptions on most real apps. | High-security sites with a team to tune them. |
| 4 | Very strict, close to an allowlist of plain characters. Many false alarms. | Small, well-known APIs and experiments. |
A request is blocked when its anomaly score reaches 5. A single critical match (score 5) is enough; lesser matches add up. The score is shown for each event.
Raising the level on a site already in block mode can block real users. Switch the site to monitor first, raise the level, watch for a while, then switch back.
Fail open or closed
What happens when the WAF can't inspect a request because of an internal error (not because it found an attack):
| Value | Behaviour |
|---|---|
open (default) | The request is forwarded to your app anyway, and the error is logged. Your site stays up. |
closed | The request is refused with a 503 "Temporarily unavailable" page. Nothing uninspected reaches your app. |
Choose closed for sites where letting an uninspected request through is worse than a brief error, such as admin panels or payment APIs.
Security header presets
HostWall can add security headers to your app's responses. A header your app already sets is never replaced, so your own values always win.
| Header | basic | strict |
|---|---|---|
X-Content-Type-Options: nosniff | ✅ | ✅ |
X-Frame-Options: SAMEORIGIN | ✅ | ✅ |
Referrer-Policy: strict-origin-when-cross-origin | ✅ | ✅ |
Strict-Transport-Security: max-age=31536000; includeSubDomains | ✅ (HTTPS responses only) | |
Permissions-Policy: camera=(), microphone=(), geolocation=() | ✅ | |
Cross-Origin-Opener-Policy: same-origin | ✅ | |
Removes X-Powered-By | ✅ |
off adds nothing.
Be careful with strict: its HSTS header includes includeSubDomains, so browsers will insist on HTTPS for every subdomain of the site's domain for a year. Use it only when all your subdomains have HTTPS. strict also blocks camera, microphone and location access, which breaks video-call or map features.
HostWall's own pages (block, error and "site not found" pages) always send their own strict headers.
Trusted proxies
When a CDN or load balancer sits in front of HostWall, every connection comes from that proxy's address. The visitor's real IP is in a header such as X-Forwarded-For. But anyone can send that header, so HostWall only believes it when the connection comes from a trusted proxy.
server:
trusted_proxies:
- cloudflare # Cloudflare's published IP ranges
- private # 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, ::1, fc00::/7
- 203.0.113.10 # a single proxy
- 198.51.100.0/24 # a rangeHow the client IP is found:
- If the direct peer isn't trusted, its address is the client IP. Headers are ignored.
- If it is trusted, HostWall reads
X-Forwarded-Forfrom right to left and takes the first address that isn't a trusted proxy. - If that gives nothing, it tries
CF-Connecting-IP,True-Client-IPandX-Real-IP, in that order. - Otherwise it uses the peer address.
The real client IP appears in events, is used by the WAF rules, and is passed to your app. The cloudflare list is a snapshot of Cloudflare's ranges built into this release. See Running behind Cloudflare and other proxies.
File sites and dashboard sites
Sites come from two places:
| File sites | Dashboard sites | |
|---|---|---|
| Defined in | sites: in the YAML file | The dashboard, or hostwall site add |
| Stored in | The YAML file | The database in the data directory |
| Editable in the dashboard and CLI | Protection settings only (see below) | Yes, everything |
| "Allow this" exceptions | Yes | Yes |
Both kinds run side by side. If a dashboard site uses a hostname that a file site already uses, the file wins: the dashboard site is skipped and the log says skipping dashboard site "...": ....
For a file site, the dashboard and hostwall site mode can change the protection settings: mode, paranoia, fail, headers, compress, skip_paths, inspect_static and log_requests. These changes are stored in the database as overrides layered on top of the file; the YAML file is never rewritten. The domain, aliases, upstream and tls can only be changed in the file.
The dashboard marks such a site Changed here, and hostwall site list shows file (changed: mode,...). Click the reset button on the site's card to remove the overrides and go back to what the file says. Setting a value back to the file's value also removes its override. An override that would make the site invalid is ignored, with a warning in the log.
hostwall site remove refuses to remove a file site: delete it from the file.
Exceptions created with Allow this are stored in the database for both kinds of site. They aren't in the YAML file yet.
Full example
server:
http: ":80"
https: ":443"
dashboard: "127.0.0.1:9443"
metrics: "127.0.0.1:9180"
trusted_proxies: [cloudflare]
body_inspect_limit: 1MB
event_retention_days: 30
tls:
email: admin@example.com
defaults:
mode: monitor
paranoia: 1
fail: open
headers: basic
sites:
- domain: example.com
aliases: [www.example.com]
upstream: http://localhost:3000
mode: block
- domain: api.example.com
upstream:
- http://10.0.0.5:8080
- http://10.0.0.6:8080
paranoia: 2
headers: strict
fail: closed
- domain: internal.example.com
upstream: localhost:9000
tls: "off" # TLS is handled by another proxy in front
mode: "off" # proxy only, no inspectionThe repository also has a commented example file and a local test setup.