【问题标题】:Request is missing required `Host` header error in Scala Play 2.6.7 AkkaScala Play 2.6.7 Akka 中的请求缺少必需的“主机”标头错误
【发布时间】:2017-11-23 02:16:35
【问题描述】:

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

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`

【问题讨论】:

    标签: scala playframework akka


    【解决方案1】:

    haproxy 服务器健康检查未将 Host 标头发送到服务器

    haproxy httpchk 应该这样修改

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

    【讨论】:

      【解决方案2】:

      根据您的 HAProxy 版本,支持的语法可能会有所不同。这似乎适用于 HAProxy 2.0.x

      option httpchk GET /health
      http-check send hdr Host localhost
      

      请务必检查 the documentation 的版本。

      【讨论】:

        猜你喜欢
        • 2018-02-03
        • 2015-04-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-23
        • 2022-01-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多