diff --git a/config/environments/development.rb b/config/environments/development.rb index 9bd43d1..892ad2e 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_HOSTS_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOSTS_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..deeddce 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_HOSTS_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOSTS_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..5d4d09a 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_HOSTS_REGEX"].present? + config.hosts << Regexp.new(ENV['ALLOWED_HOSTS_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..583252e 100644 --- a/example.env +++ b/example.env @@ -7,6 +7,12 @@ 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= +# Restart nginx after modifying HOST_NAME and/or ALLOWED_HOSTS_REGEX + BUNDLE_GEMFILE=Gemfile # BUNDLE_PATH=/app/scholarspace/bundle CH12N_TOOL=fits_servlet @@ -70,4 +76,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=