Docs Config Rematch

Rematch

Strictly speaking this isn't a real proxy protocol, but a special outbound type: when matched, it doesn't actually open a connection โ€” instead it tags the traffic and re-runs it through rule matching (or jumps to a specific sub-rule).

Example Config

config.yaml YAML
proxies:
  - name: "rematch"
    type: rematch
    target-rematch-name: "rematch1"
    target-sub-rule: "sub-rule1"

Field Reference

target-rematch-nameOptional

Overwrites the rematch-name tag in the traffic's metadata, which can then be matched using a REMATCH-NAME rule.

target-sub-ruleOptional

When set, matching jumps straight into the specified sub-rule; if the name doesn't exist or is left blank, it falls back to the main rules.

Usage Example

Tag and Continue Matching the Main Rules
YAML rematch-name
proxies:
  - name: "mark-streaming"
    type: rematch
    target-rematch-name: "streaming"

rules:
  - REMATCH-NAME,streaming,Streaming
  - DOMAIN-SUFFIX,netflix.com,mark-streaming
  - MATCH,DIRECT

The first time a request matches DOMAIN-SUFFIX,netflix.com,mark-streaming, the traffic gets tagged with rematch-name: streaming and re-enters rule matching โ€” this time it will match the earlier REMATCH-NAME,streaming,Streaming rule first.

The REMATCH-NAME rule must be placed before the rule that triggers the rematch โ€” otherwise re-matching could hit the same rematch outbound again, causing an infinite loop.

Jumping to a Sub-Rule
YAML sub-rule
proxies:
  - name: "use-ai-rules"
    type: rematch
    target-sub-rule: "ai-rules"

rules:
  - DOMAIN-SUFFIX,openai.com,use-ai-rules
  - MATCH,DIRECT

sub-rules:
  ai-rules:
    - DOMAIN-SUFFIX,openai.com,AI
    - MATCH,DIRECT

Once use-ai-rules is matched, matching jumps straight to the ai-rules sub-rule. It's a good idea to add a MATCH fallback rule inside the sub-rule to avoid ending up with no match at all.