2
votes

I have some Rails 6 applications, deployed at AWS, via Opsworks.

After upgrading to Rails 6 the app blocks the health check of its own instance and it causes the load balancer to take the instance down.

I would like to know how to whitelist all my EC2 instances automatically with dynamic IP addresses? Instead of adding one by one to config/application.rb?

Thanks

Rails.application.configure do
  # Whitelist one hostname
  config.hosts << "hostname"
  # Whitelist a test domain
  config.hosts << /application\.local\Z/
  # config.hosts.clear 
end
2

2 Answers

1
votes

The work-around that worked for me was

config.hosts.clear
0
votes

I posted this question a while back. A safer solution would be reading the IP addresses from environmental variables that can be set from the AWS console.

config.hosts << ENV["INSTANCE_IP"]
config.hosts << ENV["INSTANCE_IP2"]
...
config.hosts << ENV["INSTANCE_IPn"]

At least in this way it does not require a new git commit every time the IP address changes when the instance has a dynamic IP.