简体   繁体   中英

HAproxy and Node.js+Spdy

I'm currently using node spdy to serve files. This works beautifully.

However I would like to use HAproxy to load balance amongst these node servers. But when my node/spdy server is behind HAproxy, request.isSpdy is false ... so spdy is all of a sudden not supported?

Here's my HAproxy configuration: global 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. 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.

For an example HAProxy + SPDY config script, see here: 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.

 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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