【问题标题】:Getting 504 gateway timeout error when accessing node application through haproxy通过 haproxy 访问节点应用程序时出现 504 网关超时错误
【发布时间】:2020-04-14 11:41:53
【问题描述】:

在使用 node/express 应用程序配置 haproxy 时,我面临以下情况。我在尝试着 实现追随。

    (https)         (http)

浏览器 ======> haproxy =====> 节点应用程序

通过浏览器加载节点应用程序时,我收到 http 504 网关超时错误。

以下是我的 haproxy 配置。 haproxy configurations

以下是 haproxy 日志。

vm-2 haproxy[21255]: 127.0.0.1:45948 [23/Dec/2019:10:57:51.411] https-in~ servers/server1 0/0/0/-1/100001 504 194 - - sH-- 1/1/0/0/0 0/0 "GET / HTTP/1.1"
vm-2 haproxy[21255]: 127.0.0.1:45948 [23/Dec/2019:10:57:51.411] https-in~ servers/server1 0/0/0/-1/100001 504 194 - - sH-- 1/1/0/0/0 0/0 "GET / HTTP/1.1"
vm-2 haproxy[21255]: 127.0.0.1:46122 [23/Dec/2019:10:59:31.435] https-in~ servers/server1 0/0/0/-1/100002 504 194 - - sH-- 1/1/0/0/0 0/0 "GET /favicon.ico HTTP/1.1"

任何帮助将不胜感激。

【问题讨论】:

    标签: haproxy


    【解决方案1】:

    您的 haproxy 日志表明请求完成需要 100 多秒(即 100001/100002),并且在后端服务器可以发送完整响应之前它被中止(即 -1)。

    如果您正在寻找严格的 haproxy 解决方案(即,您不能/不会调整您的应用程序),那么您需要使用 haproxy 超时设置。

    【讨论】:

      【解决方案2】:

      我们遇到了同样的问题,客户端对服务器的请求是由 HAProxy 发送的 504。我们发现haproxy.cfg 文件中的defaults 配置具有定义504 响应的timeout server 属性(将其设置为较低的值,在我们的例子中为1s,将自动导致504)。增加该值是在代理和后端之间建立更长连接的一种方式。

      【讨论】:

        猜你喜欢
        • 2019-09-03
        • 1970-01-01
        • 2021-04-05
        • 2019-12-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-08
        相关资源
        最近更新 更多