2016-07-10 69 views
0

我正在使用HAProxy作爲負載平衡器並終止SSL。在這之後我放置了一個Nginx。我想用spdy/3.1。SPDY與HAProxy和Nginx

它不適用於以下haproxy.confnginx.cfg。 (文件是serverd,但根據Chrome SPDY/HTTP2 Indicator Plugin它只是普通的HTTP/1.1流量)。

我試圖去除不必要的部分。

我在做什麼錯?你有調試技巧嗎?

(HAProxy的1.6電流和NGINX 1.10穩定線)

haproxy.cfg:

global 
    daemon 
    tune.ssl.default-dh-param 2048 

defaults 
    mode tcp 

frontend myfrontend 
    bind *:80 
    bind *:443 ssl crt /etc/ssl/certificate.pem npn spdy/3.1,http/1.1 ciphers ECDH+AESGCM:HIGH:!aNULL:!MD5:!DSS:!RC4; no-sslv3 
    acl istoplevel path/
    redirect scheme https if istoplevel !{ ssl_fc } 
    redirect location/if !istoplevel !{ ssl_fc } 
    rspadd Strict-Transport-Security:\ max-age=31536000; 
    default_backend mybackend 

backend mybackend 
    server s1 localhost:81 
    option forwardfor 
    http-request set-header X-Forwarded-Port %[dst_port] 
    http-request add-header X-Forwarded-Proto https if { ssl_fc } 

nginx.conf:

user nginx; 

http { 
    include  /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    sendfile  on; 
    #tcp_nopush  on; 

    server { 
    listen 81 spdy; 
    root /usr/share/nginx/html; 
    index index.html; 

    location/{ 
     try_files $uri $uri/ /index.html; 
    } 
    } 
} 
+0

Nginx的是建立與--with-http_v2模塊。那包括spdy?文檔沒有那麼詳細 – nxrd

回答

1

Chrome不支持任何SPDY更多: http://blog.chromium.org/2016/02/transitioning-from-spdy-to-http2.html?m=1

它不支持HTTP/2在很多情況下:https://ma.ttias.be/day-google-chrome-disables-http2-nearly-everyone-may-31st-2016/

另外,如果您終止於HAproxy,Nginx究竟在做什麼並不重要。我不確定HAproxy是否支持SPDY?有些帖子建議它does with special config,其他人說它正在等待HTTP/2。

最終SPDY即將出臺。即使它的發明者不會支持它,你也知道你正在失敗。你會更好地轉向HTTP/2。

+0

我知道,但用於nodejs的http/2模塊的主模塊僅支持TLS,因爲我在haproxy中終止了ssl,所以我無法使用它 – nxrd

+0

nodejs從哪裏來!!!在原始問題中完全沒有提及。那是Nginx的背後嗎?最終,HAproxy和Nginx之間的連接以及其他任何你所擁有的並不重要。它可能會有如此低的延遲,以至於超過HTTP/1.1的任何好處都會產生微不足道的影響。您關心的是客戶端瀏覽器和HAProxy之間的連接 - 使用SPDY或最好是HTTP/2來查看大部分優點。順便說一下,它不需要一直是一個協議,因爲只要您終止SSL,您也會終止連接並從此開始一個新連接。 –

+0

Nodejs是除haginxy負載平衡的nginx之外的另一種服務。這不是問題的一部分,但是當我決定採用SPDY時,我考慮到了這一點,這就是爲什麼我在評論中提到它。所以好吧,然後我會嘗試去http/2。我認爲這隻有在SPDY/http2一直下降的情況下才有意義:D感謝至今:)當我遇到問題時,我會回覆您 – nxrd

0

您需要爲Chrome使用ALPN。對於HAProxy,您需要1.8才能支持HTTP2。

下面是HTTP2和ALPN相關的配置從CertSimple的load balancer with HTTP/2 and dynamic reconfig指南:

frontend public 
    # HTTP/2 - see https://www.haproxy.com/blog/whats-new-haproxy-1-8/ 
    bind :443 ssl crt /etc/https/cert-and-private-key-and-intermediate-and-dhparam.pem alpn h2,http/1.1