nginx 编译
tar -zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0/
./configure --with-http_v2_module --with-http_ssl_module
make && make install
修改 nginx.conf
listen 443 后面追加 ssl http2
server {
listen 443 ssl http2;
server_name www.ploughman.top ploughman.top;
ssl on;
root html;
index index.html index.htm;
ssl_certificate cert-www/1527659864095.pem;
ssl_certificate_key cert-www/1527659864095.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:3999;
}
}
reload
# 测试 配置文件 是否正确
nginx -t
# 热 reload
nginx -s reload
检测
- chrome
- 浏览器
chrome://net-internals/#http2
可以查看到当前使用h2的网站列表 - 安装
HTTP/2 and SPDY indicator
插件 在访问h2 的网站时 会有闪电的标志
- 浏览器
-
firefox
- f12 打开开发者模式