# Origin Rules

Origin Rules change where Cloudflare sends a request, or how the request reaches the origin, for traffic matching a filter expression. Available overrides: origin server (resolve override), Host header, SNI, destination port, and DNS resolution.

## Use cases

- Route `/api/*` to a different backend than the rest of the site, without separate hostnames or DNS changes.
- Override the Host header when the origin expects a different hostname than the public one.
- Point a path at a third-party service or a server on a non-standard port.

## Requirements and ordering

- The DNS records for the domain must be **proxied** through Cloudflare; Origin Rules do nothing on DNS-only records.
- Origin Rules execute in the rules order (after Configuration Rules, before Bulk Redirects). Within the ruleset, the last non-terminating change wins for the same override.

## The failure modes

- Setting a resolve override to a hostname that does not resolve: every matching request fails. Test the override target with `dig` first.
- Host header override breaking origin virtual hosting: the origin routes by Host; overriding it to something the origin does not recognize returns the wrong site or a 404. Confirm the origin expects the overridden value.
- Forgetting DNS-only records bypass Origin Rules entirely: if half your hostnames are gray-clouded, the rule silently does not apply to them.

## Checklist

- Proxy the records first, then write the rule.
- Verify the override target resolves and the origin answers for the overridden Host.
- Trace a request to confirm the rule fired and the origin received.