Blog | Phodal - A Growth Engineerhttp://www.phodal.com/blog/2015-08-25T05:59:01.693176+00:00BlogMac OS Curl HTTP/2 支持2015-08-25T05:55:56+00:002015-08-25T05:59:01.693176+00:00Phodal Huanghttp://www.phodal.com/blog/author/root/http://www.phodal.com/blog/curl-with-http2/尝试了几次用Curl来抓取HTTP2的内容
/usr/local/Cellar/curl/7.43.0/bin/curl --http2 http://www.phodal.com/
curl: (1) Unsupported protocol
发现一直提示:``Unsupported protocol``
后来发现少了``nghttp2``选项
##Curl With HTTP2
于是添加with-nghttp2
brew install curl --with-nghttp2
nghtt2是HTTP/2 C Library
接着,再次测试
fdhuang ⓔ test master ~/learing/lan /usr/local/Cellar/curl/7.43.0/bin/curl -I -s --http2 https://www.phodal.com/ -A google
HTTP/2.0 200
server:phodal/0.19.4
content-type:text/html; charset=utf-8
vary:Accept-Encoding
vary:Accept-Language, Cookie
content-language:en
x-ua-compatible:IE=Edge,chrome=1
date:Tue, 25 Aug 2015 05:51:01 GMT
x-page-speed:Powered By Phodal
cache-control:max-age=0, no-cache
看样子是支持了Nginx HTTP2 编译 2015-08-21T14:32:18+00:002015-08-21T15:45:35.143218+00:00Phodal Huanghttp://www.phodal.com/blog/author/root/http://www.phodal.com/blog/nginx-194-with-http2-install/看到了一些关于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](www.phodal.com)就有了~~
![Nginx HTTP2][1]
[1]: /static/media/uploads/nginx_http2.jpg