nginx HTTP2 编译安装

IT-Pony 2016-03-29 AM 443℃ 0条
    看到了一些关于HTTP2的传闻,于是就想着升级网站的Nginx,让他支持HTTP2.0,顺便也编译一下新的ngx_pagespeed,也是有近一年没有更新nginx了。
前提:
    1.需要https证书
    2.需要有 OpenSSL 1.0.2+
安装
以下步骤适合于LNMP安装。
1.下载Nginx
    wget http://nginx.org/download/nginx-1.9.4.tar.gz
2.下载和编译
    tar xvfz nginx-1.9.4.tar.gz
    cd nginx-1.9.4
3.打patch
    wget http://nginx.org/patches/http2/patch.http2.txt
    patch -p1 < patch.http2.txt
4.配置
    ./configure --with-http_ssl_module \
  --with-http_v2_module \
  --with-debug \
  --with-openssl=/path/to/openssl-1.0.2
    如果你和我一样有各种模块,那么配置可能是下面这样子的
    ./configure --user=www --group=www --add-module=../ngx_pagespeed-release-1.9.32.6-beta --        prefix=/usr/local/nginx --with-pcre --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-    ipv6
5.编译
    make
6.修改配置如下
    server {
         listen 443 default_server ssl http2;
         ssl_certificate      server.crt;
         ssl_certificate_key  server.key;
    }
7.更新
    mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
    cp objs/nginx /usr/local/nginx/sbin/nginx
    /usr/local/nginx/sbin/nginx -t
    make upgrade
8.查看
    chrome://net-internals/#http2
接着搜索phodal.com就有了~~
9.测试 http2 的时候 chrome 中出现 RR_SPDY_INADEQUATE_TRANSPORT_SECURITY 的错误代码
    原因是 HTTP/2 协议中对 TLS 有了更严格的限制,HTTP/2 中只能使用 TLSv1.2+,并且禁用了很多 CipherSuite,所以我们参考 cloudflare 来配置如下:
    ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;
标签: none

非特殊说明,本博所有文章均为博主原创。

评论啦~