【发布时间】:2016-05-05 21:14:59
【问题描述】:
我有 3 个 nodejs 网络服务器在 ubuntu 机器上旋转,HAproxy 用于在同一个机器上对这些服务器进行负载平衡。 HAproxy 侦听端口 80(http) 和 443(https,使用 SSL 终止)。 HAproxy 服务器和 Web 服务器之间没有 SSL。
对没有 SSL 的 api 之一的 POST 调用以任何内容长度值通过,但是当我尝试在具有 SSL 连接(端口 443)的 HAproxy 上执行内容长度大于 8055 的 POST 调用时, HAproxy 超时,出现 504 网关超时错误。
另外,如果我给 curl 命令一个“Expect:100 continue”标头,服务器会响应一些延迟,这是我不希望存在的。下面是 HAproxy 配置文件的样子:
global
stats socket /var/run/haproxy.sock mode 0777
log 127.0.0.1 local0 info
log 127.0.0.1 local1 info
chroot /usr/share/haproxy
uid nobody
gid nobody
nbproc 1
daemon
maxconn 50000
frontend localnodes:https
bind *:443 ssl crt /etc/ssl/private/443_private_ssl_in.pem no-sslv3
mode http
reqadd X-Forwarded-Proto:\ https
default_backend nodes
timeout client 30000
frontend localnodes-http
bind *:80
mode http
reqadd X-Forwarded-Proto:\ http
default_backend nodes
timeout client 30000
backend nodes
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
log global
timeout connect 3000
timeout server 30000
option httplog
option ssl-hello-chk
option httpchk GET /
http-check expect status 404
server nodejsweb01 127.0.0.1:8000 check
server nodejsweb02 127.0.0.1:8001 check
server nodejsweb03 127.0.0.1:8002 check
我确保后面的 nodejs 网络服务器没有问题,它们工作正常。我尝试增加“超时服务器”期限,但没有效果。 还在this link 上尝试了一个解决方案,告诉为后端节点提供一个选项 ssl ca-file,如下所示:
server nodejsweb01 127.0.0.1:8000 ssl ca-file /etc/ssl/certs/ca.pem check
server nodejsweb02 127.0.0.1:8001 ssl ca-file /etc/ssl/certs/ca.pem check
server nodejsweb03 127.0.0.1:8002 ssl ca-file /etc/ssl/certs/ca.pem check
但是在这个选项之后,HAproxy 会抛出一个错误,说后端没有可用的服务器。
请告诉我我在 HAproxy conf 文件中做错了什么,以便让网络服务器通过 SSL 连接成功响应
【问题讨论】:
-
您是否尝试过使用最低限度的仅 HTTP 配置?例如
frontend/bind/mode http/default_backend,backend/mode http/httplog/httpchk/server -
是的,使用最低限度的 http-only 配置(无 ssl),服务器会及时响应您提供的任何内容长度...仅在使用 ssl 连接时,haproxy 超时
-
什么版本的HAProxy?
-
1.5-dev21-6b07bf7,我猜它是 2014 年发布的