Skip to content

Commit

Permalink
Merge pull request #88 from alphagov/add-rate-limiting
Browse files Browse the repository at this point in the history
Enable edge rate limiting
  • Loading branch information
theseanything authored Jul 12, 2024
2 parents 6cdeb93 + 153e0c4 commit e31e140
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
18 changes: 18 additions & 0 deletions modules/assets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ resource "fastly_service_vcl" "service" {
}
}

rate_limiter {
name = "rate_limiter"

rps_limit = 500
window_size = 10
penalty_box_duration = 5

client_key = "req.http.Fastly-Client-IP"
http_methods = "GET,PUT,TRACE,POST,HEAD,DELETE,PATCH,OPTIONS"

action = "response"
response {
content = "Too many requests"
content_type = "plain/text"
status = 429
}
}

dynamic "logging_splunk" {
for_each = {
for splunk in lookup(var.secrets, "splunk", []) : splunk.name => splunk
Expand Down
18 changes: 18 additions & 0 deletions modules/bouncer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ resource "fastly_service_vcl" "service" {
})
}

rate_limiter {
name = "rate_limiter"

rps_limit = 500
window_size = 10
penalty_box_duration = 5

client_key = "req.http.Fastly-Client-IP"
http_methods = "GET,PUT,TRACE,POST,HEAD,DELETE,PATCH,OPTIONS"

action = "response"
response {
content = "Too many requests"
content_type = "plain/text"
status = 429
}
}

dynamic "logging_s3" {
for_each = {
for s3 in lookup(var.secrets, "s3", []) : s3.name => s3
Expand Down
18 changes: 18 additions & 0 deletions modules/datagovuk/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ resource "fastly_service_vcl" "service" {
force_ssl = true
}

rate_limiter {
name = "rate_limiter"

rps_limit = 500
window_size = 10
penalty_box_duration = 5

client_key = "req.http.Fastly-Client-IP"
http_methods = "GET,PUT,TRACE,POST,HEAD,DELETE,PATCH,OPTIONS"

action = "response"
response {
content = "Too many requests"
content_type = "plain/text"
status = 429
}
}

dynamic "logging_splunk" {
for_each = {
for splunk in lookup(var.secrets, "splunk", []) : splunk.name => splunk
Expand Down
18 changes: 18 additions & 0 deletions modules/www/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ resource "fastly_service_vcl" "service" {
}
}

rate_limiter {
name = "rate_limiter"

rps_limit = 500
window_size = 10
penalty_box_duration = 5

client_key = "req.http.Fastly-Client-IP"
http_methods = "GET,PUT,TRACE,POST,HEAD,DELETE,PATCH,OPTIONS"

action = "response"
response {
content = "Too many requests"
content_type = "plain/text"
status = 429
}
}

dynamic "logging_splunk" {
for_each = {
for splunk in try(var.secrets["splunk"], []) : splunk.name => splunk
Expand Down

0 comments on commit e31e140

Please sign in to comment.