From 4aef267227f0005beb09d61b954488a0a65e255c Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Tue, 8 Oct 2024 10:53:40 +0100 Subject: [PATCH] Configure hosts for application Prevents `Host` header attacks. Note: the healthcheck endpoints are requested by IP, not domain, so we need to specifically exclude them from the protection. --- config/environments/production.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 68acd5e1d..d3a7697d4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -79,10 +79,10 @@ config.active_record.dump_schema_after_migration = false # Enable DNS rebinding protection and other `Host` header attacks. - # config.hosts = [ - # "example.com", # Allow requests from example.com - # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` - # ] + config.hosts = [ + /transition\..*gov.uk?/, + ] + # Skip DNS rebinding protection for the default health check endpoint. - # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } + config.host_authorization = { exclude: ->(request) { request.path.match?("^\/healthcheck") } } end