Skip to main content

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​

  1. Go to Domains → select a domain → Header Rules tab. Go to Domains → select a domain → Header Rules tab
  2. Click Add Rule.
  3. 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.
  4. Click Save (each rule is saved separately) and wait a few seconds for it to sync.

Configuration fields​

FieldMeaningValuesDefaultNotes
PhaseApply to the request (→ origin) or the response (→ client)request / responseresponseDetermines which direction the rule runs in
ActionType of operationset (overwrite) / append (add to) / remove (delete)setWith remove, Header Value must be empty
Header NameHeader nameRequired, printable characters, no :——
Header ValueHeader valueString, no CR/LFEmptyMust be empty when Action = remove
ConditionCondition for applying the rule (WAF expression)Valid expressionEmpty (= always apply)Invalid syntax → 400
PriorityOrder of application within the same phase-1000..10000The 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 · Action set · Header Name X-Served-By · Header Value VNIS · 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 · Action set · Header Name X-From-Edge · Header Value 1 · Condition http.uri.path starts_with "/api"
  • Result: only requests to /api/* send X-From-Edge: 1 to 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 · Action remove · Header Name X-Powered-By · Header Value empty
  • Result: the X-Powered-By header is removed from the response returned to the client.
  • Check: curl -I → X-Powered-By is 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 set rules 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.
  • Rules with a condition are applied only when the edge can evaluate the condition for that request or response.
  • request rules are applied when the request to the origin is built; response rules are applied to the response (on both cache hits and misses).

Troubleshooting​

SymptomCommon causeFix
Saving returns 400 "must be empty when action is 'remove'"Action = remove but a Value was enteredClear Header Value
Saving returns 400 about the header nameThe name contains :/spaces/invalid charactersUse a valid header name
Saving returns 400 about the conditionThe expression has a syntax error or uses a field that does not existFix the expression; use fields from the list in Configuration fields
remove Server has no effectserver/via/HSTS… are protected by the edgeThese headers cannot be removed with Header Rules
set Authorization is not appliedauthorization is blocked (all actions)Use another method (not Header Rules)
Several rules on the same header give unexpected resultsMisunderstanding 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 set on 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 with via, HSTS, x-frame-options, x-content-type-options, x-xss-protection), so remove is 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 set overwrite, 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).