Fastly Setup for hlx.live
NOTE: The instructions linked on this page apply to the previous version of Edge Delivery Services and are provided for customers who have not upgraded to aem.live yet. The current version of this document is provided here.
The following screenshots illustrate how to configure Fastly to deliver content. Essential settings are marked with a red circle.
Create a Fastly service
Go to the Fastly Management UI and select Create Service:
Add Domain
Add your production domain (e.g. www.mydomain.com
):
Configure Origin
Add your origin (e.g. main--mysite--hlxsites.hlx.live
):
Click on the pencil to edit the new origin:
Scroll down and change Shielding to Ashburn Metro (IAD)
(non-mandatory but recommended setting) and Override host to the hostname of your origin (same as Address above, e.g. main--mysite--hlxsites.hlx.live
) (mandatory setting):
Enable Gzip
Create VCL Snippets
Create a VCL snippet for the recv
subroutine with the following VCL code:
if (fastly.ff.visits_this_service == 0) {
# edge delivery node
if (req.url.qs != "") {
# remember query string
set req.http.X-QS = req.url.qs;
if (req.url.path !~ "/media_[0-9a-f]{40,}[/a-zA-Z0-9_-]*\.[0-9a-z]+$"
&& req.url.ext !~ "(?i)^(gif|png|jpe?g|webp)$"
&& req.url.ext != "json"
&& req.url.path != "/.auth") {
# strip query string from request url
set req.url = req.url.path;
}
}
}
Create VCL snippets for the miss
and pass
subroutines with the following VCL code:
set bereq.http.X-BYO-CDN-Type = "fastly";
set bereq.http.X-Push-Invalidation = "enabled";
NB: The X-Push-Invalidation: enabled
request header enables the push invalidation incl. long cache TTLs.
miss
snippet:
pass
snippet:
Create a deliver
snippet with the following VCL code:
if (fastly.ff.visits_this_service == 0) {
# on edge delivery node
if (
http_status_matches(resp.status, "301,302,303,307,308")
&& req.http.X-QS
&& resp.http.location
&& resp.http.location !~ "\?.*\z"
) {
# preserve request query string in redirect location
set resp.http.location = resp.http.location "?" req.http.X-QS;
}
}
Finally create a deliver
snippet with the following VCL code:
unset resp.http.Age;
if (req.url.path !~ "\.plain\.html$") {
unset resp.http.X-Robots-Tag;
}
After completing all steps and activating the service version you should be all set:
Note
Your Fastly setup should not use Fastly’s Next Generation Web Application Firewall for requests that are going against hlx.live or any other Edge Delivery Services origin. Enabling WAF with Edge Delivery Services can lead to erroneous content being delivered.
Edge Delivery Services needs no Web Application Firewall, as it is running on hardened, shared, and ultra-scalable infrastructure. Requests that a WAF would typically intercept are terminated in our CDNs.
Previous