简体   繁体   English

HAproxy和Node.js + Spdy

[英]HAproxy and Node.js+Spdy

I'm currently using node spdy to serve files. 我目前正在使用node spdy来提供文件。 This works beautifully. 这很漂亮。

However I would like to use HAproxy to load balance amongst these node servers. 但是,我想使用HAproxy在这些节点服务器之间进行负载平衡。 But when my node/spdy server is behind HAproxy, request.isSpdy is false ... so spdy is all of a sudden not supported? 但是,当我的节点/间谍服务器位于HAproxy后面时, request.isSpdyfalse …突然不支持spdy吗?

Here's my HAproxy configuration: global maxconn 4096 这是我的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

Thanks! 谢谢!

You can't use HAProxy's HTTP load balancing mechanism with SPDY. 您不能在SPDY中使用HAProxy的HTTP负载平衡机制。 First, you need to use the latest development branch to enable support for NPN (and hence SPDY), and after that, you will have to configure it to run closer to simple TCP load-balancing mode -- HAProxy does not understand SPDY. 首先,您需要使用最新的开发分支来启用对NPN(因此也支持SPDY)的支持,然后,您必须对其进行配置以使其更接近简单的TCP负载平衡模式运行-HAProxy无法理解SPDY。

For an example HAProxy + SPDY config script, see here: http://www.igvita.com/2012/10/31/simple-spdy-and-npn-negotiation-with-haproxy/ 有关HAProxy + SPDY配置脚本的示例,请参见此处: http : //www.igvita.com/2012/10/31/simple-spdy-and-npn-negotiation-with-haproxy/

I ran into this same issue. 我遇到了同样的问题。 Instead of using spdy, I went back to using express and made haproxy use the http/2 protocol. 我不再使用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

the key here is this part alpn h2,http/1.1 这里的关键是这部分alpn h2,http/1.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM