Appearance
Response headers, HSTS and error pages Since v0.1
Header protection edits the answers the application sends. It adds the security headers the application forgot, sends HSTS on HTTPS answers, removes headers that reveal software versions, and replaces upstream error pages with a page that carries the event reference.
Before you begin
- Role:
operatorfor the application (viewercan read the settings and the posture). - HSTS and
Secureneed the application on an HTTPS listener. - Response bodies are read only when a protection needs them (today: error excerpts and data leak checks).
See what the application sends first
Turn header protection on in detect mode. Nothing changes. The Posture tab lists, per content type (html, json, other), which security headers the application sends, in what share of answers, an example value, what the policy would add or remove, and the recommended headers it never sends. Each event's trace lists what would change.
text
1. Open Applications > All applications > the application > Response checks > Response headers.
2. On the Security headers tab, set Protection mode to detect, then select Preview changes and Apply.
3. Open the Posture tab.sh
waap headers set -app shop -m "header posture" mode=detect
waap headers posture -app shop -window 7dyaml
# applications[].policy.headers
headers:
mode: detectEnforce
Set mode=block, or leave it empty to follow the application. The preset decides the headers added. Header entries override the preset, and a header the application already sends is kept unless the entry says always.
| Preset | Adds |
|---|---|
none | nothing |
baseline (default) | X-Content-Type-Options, Referrer-Policy, X-Frame-Options and Cross-Origin-Opener-Policy on HTML (frame options only when the page's CSP has no frame-ancestors) |
strict | the baseline plus a report-only CSP, Cross-Origin-Resource-Policy and a restrictive Permissions-Policy, and removes X-XSS-Protection |
text
1. On the Security headers tab, choose the Preset (or select the recommended one from the Posture tab).
2. Set Protection mode to block.
3. Select Preview changes, then Apply.sh
waap headers presets
waap headers set -app shop -m "enforce headers" mode=block preset=baselineyaml
headers:
mode: block
preset: baselineAdd your own headers
Each entry has a name, a value, when to apply it and optional content types.
text
1. On the Security headers tab, open the header entries and add one: name, value, When, content types.
2. Select Preview changes, then Apply.sh
waap headers list set -app shop -list set -f headers.yaml -m "own headers"yaml
# policy.headers.set
- name: Permissions-Policy
value: "camera=()"
when: always
- name: X-Debug
when: removeReserved headers
Protocol headers, cookies, CORS answers and HSTS cannot be set here: Content-Length, Content-Type, Content-Encoding, Transfer-Encoding, Connection, Keep-Alive, Upgrade, Trailer, Te, Location, Set-Cookie, Strict-Transport-Security, Date, Access-Control-Allow-Origin and Access-Control-Allow-Credentials.
Set HSTS
HSTS is sent on answers to HTTPS requests only. An application that sends its own keeps it.
text
1. On the Security headers tab, open the HSTS group.
2. Set Max age, Include subdomains and Preload, then select Preview changes and Apply.sh
waap headers set -app shop -m "hsts" hsts.max_age=8760h hsts.include_subdomains=trueyaml
headers:
hsts: {enabled: true, max_age: 8760h, include_subdomains: true}Subdomains and preload
Turn on Include subdomains only when every subdomain serves HTTPS. Preload needs Include subdomains and a max age of at least a year, and browsers are slow to forget it.
Replace error pages
The upstream's error answers are replaced by the application's error page with the event reference. API clients that ask for JSON get {"error": ..., "reference": ...}. To keep the real error visible to operators, turn on Keep an excerpt: the event (rule headers.error.cloaked, one per path and status per minute) holds an excerpt of the upstream's body, in full when logging is unmasked and masked under pci.
text
1. Open Response checks > Response headers, Error pages tab.
2. Turn on Replace error pages and set Statuses, Status sent and Paths not replaced.
3. To use your own page, upload it there. Select Preview changes, then Apply.sh
waap headers set -app shop -m "error pages" errors.enabled=true errors.statuses=5xx,404 errors.skip=/healthz
waap pages set -app shop -kind error -m "own error page" -f error.htmlyaml
headers:
errors: {enabled: true, statuses: ["5xx", "404"], skip: ["/healthz"], capture: true}Block pages, challenge pages and error pages carry the same security headers and HSTS when header protection is in block mode. Their own Content-Security-Policy stays.
Collect CSP reports
With Collect CSP violation reports, the answers' CSP points at /.waap/csp-report, answered by inspection and never the upstream. Reports appear on the Posture tab: directive, blocked origin (never its path or query) and page. Use them to see what a CSP would break before you enforce it. Start with the strict preset's report-only CSP.
Control response bodies and compression
text
1. Open Response checks > Response headers, Response bodies tab.
2. Set Body inspected, Content types, Paths never read and Compress answers.
3. Select Preview changes, then Apply.sh
waap response get -app shop
waap response set -app shop -m "bodies" max_body=2MiB compress=trueyaml
# applications[].policy.response
response:
max_body: 2MiB
skip: ["/static/*"]
compress: trueA longer body is inspected in part, and the event says so. Compress answers lets the data plane compress answers (brotli, gzip) after inspection when the upstream did not. It turns on by itself for protections that read bodies.
Settings reference
General and HSTS
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
Header protection (policy.headers.enabled) | Adds headers, HSTS and removes version headers. Off keeps the settings. | true | true, false | all |
Protection mode (mode) | detect changes nothing and shows what would change. | empty (same as the application) | detect, block, empty | detect wins |
Preset (preset) | The built-in header set. | baseline | none, baseline, strict | block mode |
Collect CSP violation reports (csp_reports) | Points CSP reports at inspection and shows them on the Posture tab. | false | true, false | all |
Send HSTS (hsts.enabled) | Strict-Transport-Security on HTTPS answers. | true | true, false | block mode, HTTPS |
Max age (hsts.max_age) | How long browsers use HTTPS only. | 8760h | 5m to 17520h | HSTS on |
Include subdomains (hsts.include_subdomains) | Applies to every subdomain too. | false | true, false | HSTS on |
Preload (hsts.preload) | Marks the host for browser preload lists. | false | true, false | needs include subdomains and a max age of a year or more |
Removed headers and error pages
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
Remove version headers (remove_banners) | Removes Server, X-Powered-By, X-AspNet-Version, X-AspNetMvc-Version, X-Generator. | true | true, false | block mode |
Also remove (remove) | More header names to remove. | none | header names | block mode |
Replace error pages (errors.enabled) | Replaces the upstream's error answers. | false | true, false | block mode |
Statuses (errors.statuses) | Statuses replaced. | 5xx | 4xx, 5xx or single statuses such as 404 | errors on |
Status sent (errors.status) | The status of the replacing answer. | keep | keep, 500, 502, 503 | errors on |
Paths not replaced (errors.skip) | Paths whose errors pass (health checks). | none | exact or prefix ending in * | errors on |
Keep an excerpt (errors.capture) | Reads the upstream's error body and keeps an excerpt in the event. | false | true, false | errors on |
Header entry
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
name | The header. | none (required) | not a reserved header | all |
value | The value to send. | none | text | not with when: remove |
when | missing adds it only when absent, always replaces, remove deletes. | missing | missing, always, remove | block mode |
content_types | Limits the entry to these types. | all types | media types | all |
Response bodies
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
Body inspected (policy.response.max_body) | Most bytes of a body read. | 1MiB | up to 16MiB | modules that read bodies |
Content types (content_types) | Types whose bodies may be read (+json matches any type ending in it). | text/html, text/plain, text/csv, application/json, application/xml, text/xml, +json, +xml | media types | all |
Paths never read (skip) | Answers never read (static assets). | none | exact or prefix ending in * | all |
Compress answers (compress) | The data plane compresses answers after inspection. | false | true, false | all; on automatically when a module reads bodies |
Limits
| Limit | Value |
|---|---|
| Header entries | 64 |
| Response body read | 1 MiB default, 16 MiB at most |
| CSP reports | 16 KiB each, 30 per client per minute |
| Metrics | waap_response_edits_total{app,module,kind}, waap_response_bodies_total{app,result} |
Troubleshooting
A header is not added
- Cause: the mode is
detect, the application already sends it (when: missing), or the entry's content type does not match. - Check: the event trace lists what would change.
- Fix: set
mode=block, usewhen: alwaysto replace, or fix the content types.
Users cannot reach a subdomain after enabling HSTS
- Cause: Include subdomains applies HTTPS-only to subdomains that do not serve HTTPS.
- Fix: serve HTTPS everywhere, then turn it on; browsers keep HSTS until the max age ends.