在Scala Play 2.6.7 Akka中缺少请求`Host`头错误

时间:2017-11-23 02:16:35

标签: scala playframework akka

在生产模式下,服务器无法启动并继续打印以下日志。我无法访问网页。但代码在开发模式下运行良好。如何解决问题?

2017-11-23T10:04:07+08 [INFO] from play.core.server.AkkaHttpServer [main]
        Listening for HTTP on /0:0:0:0:0:0:0:0:9000
2017-11-23T10:04:08+08 [WARN] from akka.actor.ActorSystemImpl [application-akka.actor.default-dispatcher-4]
        Illegal request, responding with status '400 Bad Request': Request is 
        missing required `Host` header: Cannot establish effective URI of request 
        to `/`, request has a relative URI and is missing a `Host` header;
        consider setting `akka.http.server.default-host-header`

2017-11-23T10:04:08+08 [WARN] from akka.actor.ActorSystemImpl [application-akka.actor.default-dispatcher-3]
        Illegal request, responding with status '400 Bad Request': Request is 
        missing required `Host` header: Cannot establish effective URI of request 
        to `/`, request has a relative URI and is missing a `Host` header;
        consider setting `akka.http.server.default-host-header`

1 个答案:

答案 0 :(得分:1)

haproxy服务器运行状况检查未将Host标头发送到服务器

haproxy httpchk应该被修改为

option  httpchk GET / HTTP/1.1\r\nHost:localhost