【问题标题】:Haproxy Bad Gateway 502Haproxy 坏网关 502
【发布时间】:2014-11-11 06:25:18
【问题描述】:

所以我在 Jetty servlet 前使用 HAProxy。 目前的目标只是在一切配置完成后进行概念验证以及负载和压力测试。 但是我在配置 haproxy 时遇到问题。我知道这不是我的应用程序的问题,因为我运行了 nginx(tengine) 并且一切正常。所以它必须与 haproxy 配置有关,或者只是 haproxy 的工作方式不适合我的需求。

所以我的客户尝试做的是使用两个不同的连接连接到 haproxy 并保持它们打开:

  1. 以分块流模式连接以进行上传。
  2. 以普通模式连接,建立下载通道。

我的 haproxy.conf 文件如下所示:

global
log /dev/log    local0
log /dev/log    local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon

# Default SSL material locations
# ca-base /etc/ssl/certs
# crt-base /etc/ssl/private

# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL).
ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL
maxconn 2048

defaults
log global
mode    http
option forwardfor
option http-server-close
option  httplog
option  dontlognull
timeout connect 5000
timeout client  50000
timeout server  50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
stats enable
stats uri /stats
stats realm Haproxy\ Statistics
stats auth user:password

frontend www-http
   bind *:80
   reqadd X-Forwarded-Proto:\ http
   default_backend www-backend

frontend www-https
   bind *:443 ssl crt /etc/haproxy/server.pem
   reqadd X-Forwarded-Proto:\ https
   default_backend www-backend

backend www-backend
    redirect scheme https if !{ ssl_fc }
    server www-1 localhost:8080 check maxconn 2048

当我尝试访问端口 443 时,我的日志显示如下:

9 月 17 日 11:10:18 xxxxx-pc haproxy[15993]: 127.0.0.1:32875 [17/Sep/2014:11:10:18.464] www- https~ www-backend/www-1 0/0 /0/-1/1 502 212 - - PH-- 0/0/0/0/0 0/0 "GET /test HTTP/1.1"

任何想法可能是什么问题? 是配置问题还是?

谢谢。

【问题讨论】:

    标签: java servlets nginx jetty haproxy


    【解决方案1】:

    PH 表示 haproxy 拒绝了来自后端的标头,因为它格式错误。 http://www.haproxy.org/download/1.4/doc/configuration.txt

    PH - 代理阻止了服务器的响应,因为它无效, 不完整、危险(缓存控制)或与安全过滤器匹配。 在任何情况下,都会向客户端发送 HTTP 502 错误。一种可能 此错误的原因是 HTTP 标头名称中的语法无效 包含未经授权的字符。这也是可能的,但相当 很少见,代理阻止了来自 客户端由于语法无效,在服务器响应之前。在这个 在这种情况下,将向客户端发送 HTTP 400 错误并在 日志。

    【讨论】:

      猜你喜欢
      • 2013-09-08
      • 1970-01-01
      • 1970-01-01
      • 2019-04-11
      • 2021-10-04
      • 2014-01-25
      • 2017-06-23
      • 2019-10-03
      • 2017-11-08
      相关资源
      最近更新 更多