Skip to content

Commit

Permalink
Merge pull request #131 from alphagov/samsimpson1/bank-holidays-rate-…
Browse files Browse the repository at this point in the history
…limiter

Add rate limiter to www.gov.uk/bank-holidays.json
  • Loading branch information
samsimpson1 authored Feb 3, 2025
2 parents 88141ba + 37c7e33 commit f51965b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dictionaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ example_percentages:
bankholidaystest_percentages:
A: 99
B: 1
# Dictionary for /bank-holidays.json rate limiter
bankholidaysjson_ratelimiter:
/bank-holidays.json: 'Bank Holidays JSON'
21 changes: 21 additions & 0 deletions www/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,27 @@ resource "fastly_service_vcl" "service" {
}
}

rate_limiter {
name = "rate_limiter_bank_holidays_json"

rps_limit = 5
window_size = 10
penalty_box_duration = 1

uri_dictionary_name = "bankholidaysjson_ratelimiter"

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(local.secrets["splunk"], []) : splunk.name => splunk
Expand Down

0 comments on commit f51965b

Please sign in to comment.