“host not allowed” error when deploying a play framework application to Amazon AWS EC2

706 views
Skip to first unread message

Hawk

unread,
Dec 17, 2017, 3:21:22 AM12/17/17
to Play Framework
Hello,

I using Play 2.6.3. My App runs fine on dev mode and also on production mode on my local machine. However, after I deploy to EC2 ubuntu, and the app starts running fine. Everytime I call the app from my local machine I get the error 

Bad Request

For request 'GET /' [Host not allowed: ec2-xx-xxx-xx-xxx.compute-1.amazonaws.com:9000]

At the beginning, my application.conf in local enironment has the following 

play.filters {

  enabled = null

}

I had another configuration file on EC2 (in which I use the ec2 environment variables), and it is called 'prod.conf'. It had the same settings as the above.

So I changed 'prod.conf' with the new settings:

play.filters {

  # Enabled filters are run automatically against Play.
  # CSRFFilter, AllowedHostFilters, and SecurityHeadersFilters are enabled by default.
  # enabled += filters.ExampleFilter
enabled += play.filters.hosts.AllowedHostsFilter

  # Disabled filters remove elements from the enabled list.
  # disabled += play.filters.hosts.AllowedHostsFilter
    hosts {

    # A list of valid hosts (e.g. "example.com") or suffixes of valid hosts (e.g. ".example.com")
    # Note that ".example.com" will match example.com and any subdomain of example.com, with or without a trailing dot.
    # "." matches all domains, and "" matches an empty or nonexistent host.
    allowed = [".", ""]
  }
}


I did not build and redeploy again (not sure if I need to). I just restarted the app with the update 'prod.conf' file. Unfortunately I am still getting the same 'bad request host not allowed' response. 


Will Sargent

unread,
Dec 27, 2017, 12:31:35 AM12/27/17
to play-fr...@googlegroups.com
That is the AllowedHostsFilter -- if you look at the logs and turn them up to DEBUG, it will tell you more.

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/2b0530e5-9970-4eb1-a4e3-50c9d39786d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages