@cryptotaxi247 / infra / commits / 167f576b

terraform/nixpkgs-tarballs: copy more from cache.nixos.org

Handle 404 errors better and make sure / returns the index.html page.

zimbatm committed Aug 30, 2021 at 10:51 UTC 167f576b24500ba25cd534f8df624e5e92bcd412
1 file changed +49 -1
terraform/nixpkgs-tarballs.tf
+49 -1
@@ -224,7 +224,7 @@ locals {
224 }
225
226 resource "fastly_service_v1" "nixpkgs-tarballs" {
227 - name = local.tarballs_domain
227 + name = local.tarballs_domain
228 default_ttl = 86400
229
230 backend {
@@ -245,7 +245,55 @@ resource "fastly_service_v1" "nixpkgs-tarballs" {
245 weight = 100
246 }
247
248 + condition {
249 + name = "Generated by synthetic response for 404 page"
250 + priority = 0
251 + statement = "beresp.status == 404"
252 + type = "CACHE"
253 + }
254 +
255 + condition {
256 + name = "Match /"
257 + priority = 10
258 + statement = "req.url ~ \"^/$\""
259 + type = "REQUEST"
260 + }
261 +
262 domain {
263 name = local.tarballs_domain
264 }
265 +
266 + header {
267 + action = "set"
268 + destination = "url"
269 + ignore_if_set = false
270 + name = "Landing page"
271 + priority = 10
272 + request_condition = "Match /"
273 + source = "\"/index.html\""
274 + type = "request"
275 + }
276 +
277 + response_object {
278 + cache_condition = "Generated by synthetic response for 404 page"
279 + content = "404"
280 + content_type = "text/html"
281 + name = "Generated by synthetic response for 404 page"
282 + response = "Not Found"
283 + status = 404
284 + }
285 +
286 + snippet {
287 + content = <<-EOT
288 + if (beresp.status == 403) {
289 + set beresp.status = 404;
290 + set beresp.ttl = 86400s;
291 + set beresp.grace = 0s;
292 + set beresp.cacheable = true;
293 + }
294 + EOT
295 + name = "Change 403 from S3 to 404"
296 + priority = 100
297 + type = "fetch"
298 + }
299 }