From bd99eebebae41abcaf246c85ece6385c0f74dadf Mon Sep 17 00:00:00 2001 From: Dan Kerchner Date: Wed, 7 Jan 2026 19:41:01 +0000 Subject: [PATCH 1/3] Fixes #17 --- config/environments/development.rb | 8 ++++++++ config/environments/production.rb | 8 ++++++++ config/environments/test.rb | 8 ++++++++ example.env | 7 ++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 9bd43d1..3053a9e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,6 +12,14 @@ # Show full error reports. config.consider_all_requests_local = true + # Allowed hosts + if ENV["ALLOWED_HOST_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOST_REGEX']) + end + if ENV['HOST_NAME'].present? + config.hosts << ENV['HOST_NAME'] + end + # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join("tmp", "caching-dev.txt").exist? diff --git a/config/environments/production.rb b/config/environments/production.rb index 222735e..208c9e7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -17,6 +17,14 @@ config.consider_all_requests_local = true config.action_controller.perform_caching = true + # Allowed hosts + if ENV["ALLOWED_HOST_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOST_REGEX']) + end + if ENV['HOST_NAME'].present? + config.hosts << ENV['HOST_NAME'] + end + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true diff --git a/config/environments/test.rb b/config/environments/test.rb index d148f86..932fd18 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -23,6 +23,14 @@ config.consider_all_requests_local = true config.action_controller.perform_caching = false + # Allowed hosts + if ENV["ALLOWED_HOST_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOST_REGEX']) + end + if ENV['HOST_NAME'].present? + config.hosts << ENV['HOST_NAME'] + end + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false diff --git a/example.env b/example.env index 4293218..232283c 100644 --- a/example.env +++ b/example.env @@ -7,6 +7,11 @@ SECRET_KEY_BASE="beefaroni" RAILS_ENV=development PUMA_ENV=development +# If both ALLOWED_HOSTS_REGEX and HOST_NAME are populated, both will be allowed +# ALLOWED_HOSTS_REGEX=/.*\.compute\.amazonaws\.com/ +ALLOWED_HOSTS_REGEX= +HOST_NAME= + BUNDLE_GEMFILE=Gemfile # BUNDLE_PATH=/app/scholarspace/bundle CH12N_TOOL=fits_servlet @@ -70,4 +75,4 @@ AWS_ACCESS_KEY= AWS_SECRET_KEY= S3_BUCKET_NAME= # Optional -- for pointing Fedora to a specific path within a bucket -S3_PREFIX= \ No newline at end of file +S3_PREFIX= From 4f415a5b7aa106ba812193ab02780b73b72408f9 Mon Sep 17 00:00:00 2001 From: Dan Kerchner Date: Wed, 4 Mar 2026 19:36:39 +0000 Subject: [PATCH 2/3] Updated ALLOWED_HOST_REGEX to ALLOWED_HOSTS_REGEX --- config/environments/development.rb | 4 ++-- config/environments/production.rb | 4 ++-- config/environments/test.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 3053a9e..892ad2e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -13,8 +13,8 @@ config.consider_all_requests_local = true # Allowed hosts - if ENV["ALLOWED_HOST_REGEX"].present? - config.hosts << Regexp.new(ENV['ALLOWED_HOST_REGEX']) + if ENV["ALLOWED_HOSTS_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOSTS_REGEX']) end if ENV['HOST_NAME'].present? config.hosts << ENV['HOST_NAME'] diff --git a/config/environments/production.rb b/config/environments/production.rb index 208c9e7..deeddce 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -18,8 +18,8 @@ config.action_controller.perform_caching = true # Allowed hosts - if ENV["ALLOWED_HOST_REGEX"].present? - config.hosts << Regexp.new(ENV['ALLOWED_HOST_REGEX']) + if ENV["ALLOWED_HOSTS_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOSTS_REGEX']) end if ENV['HOST_NAME'].present? config.hosts << ENV['HOST_NAME'] diff --git a/config/environments/test.rb b/config/environments/test.rb index 932fd18..5d4d09a 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -24,8 +24,8 @@ config.action_controller.perform_caching = false # Allowed hosts - if ENV["ALLOWED_HOST_REGEX"].present? - config.hosts << Regexp.new(ENV['ALLOWED_HOST_REGEX']) + if ENV["ALLOWED_HOSTS_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOSTS_REGEX']) end if ENV['HOST_NAME'].present? config.hosts << ENV['HOST_NAME'] From 79130d094bf3c38130ca70d0d124ff1ebd2f10fd Mon Sep 17 00:00:00 2001 From: Dan Kerchner Date: Wed, 4 Mar 2026 19:52:38 +0000 Subject: [PATCH 3/3] Enhanced instructions --- example.env | 1 + 1 file changed, 1 insertion(+) diff --git a/example.env b/example.env index 232283c..583252e 100644 --- a/example.env +++ b/example.env @@ -11,6 +11,7 @@ PUMA_ENV=development # ALLOWED_HOSTS_REGEX=/.*\.compute\.amazonaws\.com/ ALLOWED_HOSTS_REGEX= HOST_NAME= +# Restart nginx after modifying HOST_NAME and/or ALLOWED_HOSTS_REGEX BUNDLE_GEMFILE=Gemfile # BUNDLE_PATH=/app/scholarspace/bundle