From 8cd11fd279ee53ba689cc9c4899f24ce03885490 Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Tue, 22 Oct 2024 13:33:34 +0100 Subject: [PATCH] Configure hosts for application - the healthcheck endpoints are requested by IP, not domain, so we need to specifically exclude them from the protection. - internal API hostname is also necessary --- config/environments/production.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 102c084c6..f5f82787c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -80,10 +80,11 @@ 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 = [ + /local-links-manager\..*\.gov.uk$/, + "local-links-manager", + ] + # 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