Host

The authority that the request is intended for.

Fastly reads this header from requests. It is defined by an external standard.

Fastly hosts multiple customer services on the same set of IP addresses, and in most cases uses the Host header to identify the service that should handle a request (the main exception to this is customers that have purchased dedicated IP address space and pinned the dedicated IPs to a specific service).

The value of the HTTP Host header is lowercased before being passed on to your Fastly service, to ensure consistent behavior of Fastly customer services and origins.

In VCL services it is assigned to the req.http.host variable. No matter how your site’s domain name is capitalized in the request, any VCL that uses the host value will result in the same cache address and therefore find the same cache object. This does not apply to req.url, which is not subject to normalization and will reflect the capitalization present on the request as it was received.

HINT: Regardless of this normalization behavior, it is always a good practice to use a case-insensitve comparison when checking equality between strings that are expected to represent hostnames, since hostnames are not case sensitive values. For example:

if (std.tolower(req.http.host) === "example.com") {

Multiple domains can be associated with a Fastly service. A common use case for the Host header inside a service configuration is to canonicalize the host:

if (req.http.host != "example.com") {
error 600; # Trigger an error in order to redirect to example.com
}

In many cases, backend servers are also operated in a similar manner, and require a specific Host to be provided in order to serve the correct content or invoke the correct process (as is the case for providers such as Heroku, AWS S3 or Google Cloud Storage). This should be done using the override host setting on the backend. Learn more about configuring the host header on backend requests.

WARNING: Avoid setting the host header in your edge code, since this may cause unexpected behavior, especially if your service has shielding enabled. It is almost always better to set the override host property when you add backends to your service configuration. Learn more about backends.