"host not allowed" 使用 Boxfuse 将播放框架应用程序部署到 Amazon AWS 时出错
"host not allowed" error when deploying a play framework application to Amazon AWS with Boxfuse
我正在尝试将使用 Scala 中的 Play Framework 编写的简单 Web 应用程序部署到 Amazon Web 服务。
Web 应用程序 运行在我的本地计算机上的开发模式和生产模式下正常,我已将其默认端口更改为 80。
我按照建议使用 Boxfuse 部署到 AWS。
我先运行 "sbt dist"
然后“boxfuse 运行 -env=prod”
一切如愿以偿。图像被融合并推送到 AWS。 AMI 已创建。实例已启动,我的应用程序已 运行ning.
i-0f696ff22df4a2b71 => 2017-07-13 01:28:23.940 [info] play.api.Play - Application started (Prod)
然后出现错误信息:
WARNING: Healthcheck (http://35.156.38.90/) returned 400 instead of 200. Retrying for the next 300 seconds ...
i-0f696ff22df4a2b71 => 2017-07-13 01:28:24.977 [info] p.c.s.AkkaHttpServer - Listening for HTTP on /0.0.0.0:80
i-0f696ff22df4a2b71 => 2017-07-13 01:28:25.512 [warn] p.f.h.AllowedHostsFilter - Host not allowed: 35.156.38.90
实例在 3 分钟后重复尝试后被终止。它给出了如下警告:
Ensure your application responds with an HTTP 200 at / on port 80
但我已确保应用程序在本地计算机中响应,并且我尝试了 Windows 和 Ubuntu,一切正常。
此外,运行ning "boxfuse run" 在本地机器上,我可以使用“http://localhost”连接到它,但仍然有错误。
希望有经验的朋友能给我一些建议。提前致谢。
ps:不确定是否相关,我将这些设置添加到 application.conf
http {
address = 0.0.0.0
port = 80
}
从错误信息来看,问题似乎与play.filters.hosts.allowed not set up in application.conf
. The filter lets you configure which hosts can access your application. More details about the Play filter is available here有关。
这是一个配置示例:
play.filters.hosts {
allowed = ["."]
}
请注意,allowed = ["."]
匹配所有主机,因此不建议在生产环境中使用。
如 Boxfuse Play Documentation 中所述:
If your application uses the allowed hosts filter you must ensure play.filters.hosts.allowed in application.conf allows connections from anywhere as this filter otherwise causes ELB healthchecks to fail. For example:
play.filters.hosts {
allowed = ["."]
}
official Play documentation 中的更多信息。
我正在尝试将使用 Scala 中的 Play Framework 编写的简单 Web 应用程序部署到 Amazon Web 服务。
Web 应用程序 运行在我的本地计算机上的开发模式和生产模式下正常,我已将其默认端口更改为 80。
我按照建议使用 Boxfuse 部署到 AWS。
我先运行 "sbt dist" 然后“boxfuse 运行 -env=prod”
一切如愿以偿。图像被融合并推送到 AWS。 AMI 已创建。实例已启动,我的应用程序已 运行ning.
i-0f696ff22df4a2b71 => 2017-07-13 01:28:23.940 [info] play.api.Play - Application started (Prod)
然后出现错误信息:
WARNING: Healthcheck (http://35.156.38.90/) returned 400 instead of 200. Retrying for the next 300 seconds ...
i-0f696ff22df4a2b71 => 2017-07-13 01:28:24.977 [info] p.c.s.AkkaHttpServer - Listening for HTTP on /0.0.0.0:80
i-0f696ff22df4a2b71 => 2017-07-13 01:28:25.512 [warn] p.f.h.AllowedHostsFilter - Host not allowed: 35.156.38.90
实例在 3 分钟后重复尝试后被终止。它给出了如下警告:
Ensure your application responds with an HTTP 200 at / on port 80
但我已确保应用程序在本地计算机中响应,并且我尝试了 Windows 和 Ubuntu,一切正常。
此外,运行ning "boxfuse run" 在本地机器上,我可以使用“http://localhost”连接到它,但仍然有错误。
希望有经验的朋友能给我一些建议。提前致谢。
ps:不确定是否相关,我将这些设置添加到 application.conf
http {
address = 0.0.0.0
port = 80
}
从错误信息来看,问题似乎与play.filters.hosts.allowed not set up in application.conf
. The filter lets you configure which hosts can access your application. More details about the Play filter is available here有关。
这是一个配置示例:
play.filters.hosts {
allowed = ["."]
}
请注意,allowed = ["."]
匹配所有主机,因此不建议在生产环境中使用。
如 Boxfuse Play Documentation 中所述:
If your application uses the allowed hosts filter you must ensure play.filters.hosts.allowed in application.conf allows connections from anywhere as this filter otherwise causes ELB healthchecks to fail. For example:
play.filters.hosts {
allowed = ["."]
}
official Play documentation 中的更多信息。