Rule Priority
This page is automatically synced from
docs-en/rules/rule-priority.md. Language: English | 中文
Rule Priority and Execution Order
Section titled “Rule Priority and Execution Order”Bifrost rule execution follows two principles.
- Routing rules are exclusive: the first matched routing rule wins. Among forwarding targets,
host-family operations (host/xhost/http/https/ws/wss) win overproxyby protocol precedence, regardless of file order. - Modification rules can merge: operations on different fields combine. For duplicate keys the behavior is protocol-specific (see below).
www.example.com host://server1.localwww.example.com host://server2.localThe request goes to server1.local because the first routing rule wins.
Duplicate-key merge semantics differ by protocol:
reqHeaders/resHeaders: first occurrence wins — a later rule with the same header key is ignored (e.g.X-Custom=value1thenX-Custom=value2yieldsvalue1).reqCookies/urlParams: last occurrence wins for the same key.reqBody/resBody/resCors: last matching rule overwrites earlier ones.statusCode: single-match — the first matching rule applies and laterstatusCoderules are ignored.
Note: the emitted order of merged urlParams is not guaranteed to follow definition order.