Override HTTP Host headers
When your application needs specialized routing (CNAME
setup or custom hosts like Heroku), you can customize the Host
header used in health checks on a per-origin or per-monitor level.
Per origin Host header override
To balance traffic across multiple hosts, add Host
headers to individual origins within the same pool.
For example, you might have a pool with origins hosted in multiple AppEngine projects or Amazon S3 buckets. You also might want to set up specific failover origins within a pool.
Since these examples require specific hostnames per origin, your load balancer will not properly route traffic without a Host
header override.
If you need an origin Host
header override, add it when creating or editing a pool. For security reasons, this header must meet one of the following criteria:
- Is a subdomain of a zone associated with this account
- Matches the origin address
- Publicly resolves to the origin address
Host header prioritization
If you set a header override on an individual origin, it will take precedence over a header override set on a monitor during health checks.
For example, you might have a load balancer for www.example.com
with the following setup:
Origin Pools:
Pool 1:
- Origin 1 (
Host
header set tolb-app-a.example.com
) - Origin 2
- Origin 1 (
Pool 2:
- Origin 3
- Origin 4 (
Host
header set tolb-app-b.example.com
)
Monitor (
Host
header set towww.example.com
)
In this scenario, health checks for Origin 1 would use lb-app-a.example.com
, health checks for Origin 4 would use lb-app-b.example.com
, and all other health checks would default to www.example.com
. For more information on updating your custom host configuration to be compatible with Cloudflare, see Configure Cloudflare and Heroku over HTTPS.
For a list of origins that override a monitor’s Host
header:
- On a monitor, select Edit.
- Select Advanced health check settings.
- If you have origin overrides, you will see Origin host header overrides.