Fetch Content from Your Origin with a Different Host Header

FAQ

Your origin selects content by the Host header of each request. When it expects a different hostname than your CDN resource serves, one proxy_set_header rule named Host on the location makes the CDN fetch with the name your origin needs.

An origin that hosts several sites, a hosting service, or a storage bucket selects what to serve by the Host header of each incoming request. When the hostname your origin expects differs from your CDN resource’s hostname, requests can reach the wrong site, return 404, or loop through redirects. The fix is one header rule on the CDN: set Host on the request sent to the origin.

Set the Host Header on Requests to the Origin

In the Resources table of your package, click the gear icon (Edit resource settings) on the resource’s row, then click Advanced settings and open the Origins tab. Expand the location card for the path that needs the override; the catch-all / covers the whole resource. In the card’s Headers group, click + Add header and compose the rule:

Setting Value
Type proxy_set_header, the type that sets a header on the request sent to the origin
Name Host
Value The hostname your origin expects, for example origin.example.com
Add a header dialog with proxy_set_header type, Host name and the origin hostname as value

Click Save. The rule appears in the location’s Headers list and counts toward its limit of 20. The address the CDN connects to does not change: that stays the Source Server (Origin) value. The override only changes the hostname named inside the request.

Verify the Override

Request a file through the CDN and read your origin’s access log: the request arrives with the Host value you set. Test with a URL that is not yet cached, because copies cached before the change keep serving until they expire or you purge them.

To manage response headers toward the visitor, including CORS, read Manage Response Headers and CORS on Your CDN. To look up every header type and its common uses, read CDN Custom Headers: Types, Limits and Common Uses.

Can’t find what you need? Our engineers are available around the clock, from quick fixes to full infrastructure design.