HAproxy和Node.js + Spdy

时间:2013-01-04 01:13:25

标签: node.js haproxy spdy

我目前正在使用node spdy来提供文件。这很好用。

但是,我想使用HAproxy在这些节点服务器之间进行负载平衡。但是当我的节点/ spdy服务器落后于HAproxy时,request.isSpdyfalse ...所以spdy突然不被支持了?

这是我的HAproxy配置:     全球         maxconn 4096

defaults
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http_proxy
    mode http
    bind *:80
    redirect prefix https://awesome.com code 301

frontend https_proxy
    mode tcp
    bind *:443
    default_backend webservers

backend webservers
    balance source
    server server1 127.0.0.1:10443 maxconn 4096
    # server server2 127.0.0.1:10444 maxconn 4096

谢谢!

2 个答案:

答案 0 :(得分:5)

您不能将HAProxy的HTTP负载平衡机制与SPDY一起使用。首先,您需要使用最新的开发分支来启用对NPN(以及SPDY)的支持,之后,您必须将其配置为更接近简单的TCP负载平衡模式 - HAProxy不了解SPDY。

有关示例HAProxy + SPDY配置脚本,请参阅此处: http://www.igvita.com/2012/10/31/simple-spdy-and-npn-negotiation-with-haproxy/

答案 1 :(得分:0)

我遇到了同样的问题。我不再使用spdy,而是回到使用express并使haproxy使用http / 2协议。

 frontend http-in
   bind *:80
   mode http
   redirect scheme https code 301

frontend https-in
    mode http
    bind *:443 ssl crt /path/to/cert.pem alpn h2,http/1.1

这里的关键是这部分alpn h2,http/1.1