折腾 HTTP/2

之前看到 ningx 1.9.5 版发布了,把 spdy 换成了 http2,安装主要参考了 这里

  1. nginx 官网上下载最新的 1.9.5 源代码,因为 HTTP/2 module 需要用到 “ALPN” OpenSSL_1.0.2 以上提供与 “NPN” OpenSSL_1.0.1 以上提供, 所以还要去 OpenSSLLibreSSL(建议用 LibreSSL 有一些新的特性)官网下载最新的 SSL 源码包并分别解压。

  2. 预编译的时候需要启用 http_v2_modulehttp_ssl_module 这两个模块:

    $ ./configure --with-openssl=/PATH/TO/LibreSSL --with-http_v2_module --with-http_ssl_module --with-ld-opt=-lrt #使用 LibreSSL
    $ ./configure --with-openssl=/PATH/TO/OpenSSL --with-http_v2_module --with-http_ssl_module  #使用 OpenSSL
  3. 然后 makemake install

  4. 在 Nginx 配置中启用站点对 HTTP/2 的支持也很方便,只需要在 listen 时加上 http2 就可以了:

    listen 443 ssl http2;

  5. 其它配置就跟 https 的配置是一样的,可以参考以前的