-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.tf
More file actions
71 lines (63 loc) · 1.81 KB
/
Copy pathmain.tf
File metadata and controls
71 lines (63 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
locals {
canonical_host = "www.nateberkopec.com"
}
provider "cloudflare" {}
resource "cloudflare_ruleset" "blog_legacy_redirects" {
kind = "zone"
name = "default"
phase = "http_request_dynamic_redirect"
zone_id = var.cloudflare_zone_id
rules {
action = "redirect"
description = "Redirect from HTTP to HTTPS [Template]"
enabled = true
expression = <<-EOT
(http.request.full_uri wildcard r"http://*")
EOT
action_parameters {
from_value {
preserve_query_string = false
status_code = 301
target_url {
expression = "wildcard_replace(http.request.full_uri, r\"http://*\", r\"https://$${1}\")"
}
}
}
}
rules {
action = "redirect"
description = "Redirect from Root to WWW [Template]"
enabled = true
expression = <<-EOT
(http.request.full_uri wildcard r"https://nateberkopec.com/*")
EOT
action_parameters {
from_value {
preserve_query_string = false
status_code = 301
target_url {
expression = "wildcard_replace(http.request.full_uri, r\"https://nateberkopec.com/*\", r\"https://www.nateberkopec.com/$${1}\")"
}
}
}
}
rules {
action = "redirect"
description = "Legacy blog URLs to /blog/:slug/"
enabled = true
expression = <<-EOT
(http.request.full_uri wildcard r"https://www.nateberkopec.com/blog/*/*/*/*.html")
EOT
action_parameters {
from_value {
preserve_query_string = true
status_code = 301
target_url {
expression = <<-EOT
wildcard_replace(http.request.full_uri, r"https://www.nateberkopec.com/blog/*/*/*/*.html", r"https://www.nateberkopec.com/blog/$${4}/")
EOT
}
}
}
}
}