Header Rules — add, modify or remove headers
Header Rules let you add, overwrite or remove HTTP headers on the request (sent to the origin) or the response (returned to the client), optionally with a condition (an expression using the same syntax as WAF expressions). Rules are managed individually (each rule is added, edited and deleted on its own), unlike CORS and Security Headers, which are saved as a whole.
Use it when you need flexible, condition-based header customization. Example: add X-Powered-By to the response, add an X-Country header based on the IP's country, or remove an unnecessary header returned by the origin.
Before you start
- The domain has been added and points to VNIS.
- If you use complex conditions, learn the WAF expression syntax (for example
http.uri.path contains "/api").
How to configure
- Go to Domains → select a domain → Header Rules tab.

- Click Add Rule.
- Choose the Phase (request/response) and Action (set/append/remove), enter the Header Name and Header Value (leave empty for remove), and optionally a Condition and Priority.
- Click Save (each rule is saved separately) and wait a few seconds for it to sync.
Configuration fields
| Field | Meaning | Values | Default | Notes |
|---|---|---|---|---|
| Phase | Apply to the request (→ origin) or the response (→ client) | request / response | response | Determines which direction the rule runs in |
| Action | Type of operation | set (overwrite) / append (add to) / remove (delete) | set | With remove, Header Value must be empty |
| Header Name | Header name | Required, printable characters, no : | — | — |
| Header Value | Header value | String, no CR/LF | Empty | Must be empty when Action = remove |
| Condition | Condition for applying the rule (WAF expression) | Valid expression | Empty (= always apply) | Invalid syntax → 400 |
| Priority | Order of application within the same phase | -1000..1000 | 0 | The edge applies rules in descending order (DESC), but the UI lists them in ascending order (ASC) — see Order of evaluation |
Available condition fields include the following (Expression mode offers more fields): http.uri.path, http.uri.query, http.host, http.method, http.user_agent, http.referer, http.content_type, http.geo.country, http.geo.asn, http.request_length, ip.src, ssl…
Rule limit per domain: the edge applies at most 500 rules per phase (request and response are counted separately). Keep each phase within this limit; rules beyond it (those with the lowest priority numbers) are not applied.
Configuration examples
Within the same phase, when several set rules target the same header, the value applied last wins (in the order the edge applies them — see Order of evaluation). Each rule's condition uses the WAF expression syntax.
Example 1 — Add a response header for the whole site.
- Phase
response· Actionset· Header NameX-Served-By· Header ValueVNIS· Condition empty - Result: every response includes
X-Served-By: VNIS. - Check:
curl -I https://example.com/→ the header is present.
Example 2 — Add a header based on a condition (only the /api path).
- Phase
request· Actionset· Header NameX-From-Edge· Header Value1· Conditionhttp.uri.path starts_with "/api" - Result: only requests to
/api/*sendX-From-Edge: 1to the origin. - Check: compare the origin logs for
/api/...requests with other paths.
Example 3 — Remove an unnecessary header returned by the origin.
- Phase
response· Actionremove· Header NameX-Powered-By· Header Value empty - Result: the
X-Powered-Byheader is removed from the response returned to the client. - Check:
curl -I→X-Powered-Byis no longer present.
Order of evaluation
- Application order is not display order. Within the same phase, the edge applies rules by descending priority (higher numbers first, lower numbers later), while the dashboard lists them in ascending order. With several
setrules on the same header, the rule with the lower priority is applied last, so its value wins. - Some headers are protected by the edge, and rules targeting them are ignored:
- No action allowed (
set/append/remove):authorization,x-amz-date,x-amz-content-sha256(protects S3 signing/credentials). - No
set/append:content-length,transfer-encoding,connection(framing headers — writing to them would corrupt the body). - No
remove:server,x-content-type-options,x-frame-options,x-xss-protection,strict-transport-security(HSTS),via.
- No action allowed (
- Rules with a condition are applied only when the edge can evaluate the condition for that request or response.
requestrules are applied when the request to the origin is built;responserules are applied to the response (on both cache hits and misses).
Troubleshooting
| Symptom | Common cause | Fix |
|---|---|---|
| Saving returns 400 "must be empty when action is 'remove'" | Action = remove but a Value was entered | Clear Header Value |
| Saving returns 400 about the header name | The name contains :/spaces/invalid characters | Use a valid header name |
| Saving returns 400 about the condition | The expression has a syntax error or uses a field that does not exist | Fix the expression; use fields from the list in Configuration fields |
remove Server has no effect | server/via/HSTS… are protected by the edge | These headers cannot be removed with Header Rules |
set Authorization is not applied | authorization is blocked (all actions) | Use another method (not Header Rules) |
| Several rules on the same header give unexpected results | Misunderstanding of the application order (edge DESC, UI ASC) | Work it out using Order of evaluation: the lower priority is applied last and wins |
FAQ
- Why is the order on the dashboard the reverse of the actual result? The dashboard lists rules in ascending priority, while the edge applies them in descending order. With
seton the same header, the rule with the lowest priority is applied last and wins. - Why can't I remove
Server? It is a header protected by the CDN (along withvia, HSTS,x-frame-options,x-content-type-options,x-xss-protection), soremoveis ignored. - How are Header Rules different from Security Headers? Security Headers only add standard headers when the response does not already have them (they do not overwrite the origin). Header Rules with
setoverwrite, and can also act on the request and apply conditions. - Is there a limit on the number of rules? Yes. The edge applies at most 500 rules per phase (request/response).