Overview
Fallback origin provides automatic failover when the primary origin encounters errors, timeouts, or returns specific status codes. The fallback is evaluated after any configured retry budget is exhausted and before error pages. If the fallback also fails, error pages are evaluated.
Capabilities
- Trigger on transport errors (connection refused, DNS failure, TLS errors)
- Trigger on request timeouts
- Trigger on specific HTTP status codes (e.g., 502, 503, 504)
- Request rules to restrict which requests are eligible for fallback
- Configurable max_depth to prevent infinite fallback chains
- Debug header option to identify fallback responses
Example
Fail over to a backup backend on errors or 5xx status codes:
proxy:
http_bind_port: 8080
origins:
"api.example.com":
action:
type: proxy
url: https://test.sbproxy.dev
fallback_origin:
action:
type: proxy
url: https://test.sbproxy.dev/health
on_error: true
on_timeout: true
on_status:
- 502
- 503
- 504
Test it:
curl -H "Host: api.example.com" http://localhost:8080/