Host not allowed

I ran into the ‘Host not allowed’ error while using the play-scala-hello-world-tutorial as an example to experiment with using Docker to deploy a web application on AWS using Elastic Beanstalk. Building and running in a Docker image locally worked no problem. My first issue occurred when I tried to manually run the Docker image on an EC2 instance. At this point I added the following to application.conf …

play.filters.disabled += play.filters.hosts.AllowedHostsFilter

After this I was able to access the hello world web app on EC2 without a problem. However, when I tried to deploy the same Docker image using Elastic Beanstalk I again got the ‘Host not allowed’ error. The environment is slightly different since the Play application is now behind a load balancer, but I expected that would not matter since the AllowedHostsFilter was disabled as described above. I was unable to reach the hello world web app until I added the following to the application.conf

play.filters.hosts.allowed += "."

Note, this was after the line for play.filters.disabled. After adding this line, the browser was able to get the expected responses from the hello world app and display the pages properly.

I don’t understand why the hello world app would behave differently when deployed as a container in Elastic Beanstalk vs. launching directly using Docker. Even though this is just a learning example, it may be uncovering some unexpected behavior in the filtering hierarchy. Or maybe there are some environment variables in the Elastic Beanstalk environment that I’m unaware of that could explain this.

Can anyone explain why the Play app behaves different in the Elastic Beanstalk environemnt?