diff --git a/terragrunt/modules/release-distribution/fastly-static.tf b/terragrunt/modules/release-distribution/fastly-static.tf index 760c4f786..0e015ee83 100644 --- a/terragrunt/modules/release-distribution/fastly-static.tf +++ b/terragrunt/modules/release-distribution/fastly-static.tf @@ -47,6 +47,16 @@ resource "fastly_service_vcl" "static" { VCL } + snippet { + name = "detect doc/master requests" + type = "recv" + content = <<-VCL + if (req.url ~ "^\/doc\/master\/") { + error 619 "redirect"; + } + VCL + } + snippet { name = "enable segmented caching" type = "recv" @@ -120,7 +130,7 @@ resource "fastly_service_vcl" "static" { name = "redirect /doc/master to /stable" type = "error" content = <<-VCL - if (req.url ~ "^\/doc/master(\/|$)")?$") { + if (obj.status == 619 && obj.response == "redirect") { set obj.status = 301; set obj.response = "Moved permanently"; set obj.http.Location = regsub(req.url, "^\/doc\/master", "https://doc.rust-lang.org/stable");