在CentOS 6.8 x86_64的nginx 1.10.3上开启http2功能
2017-08-16 19:29
591 查看
在原有基础上修改编译选项来开启http2
回见
http://blog.csdn.net/tao_627/article/details/60957521
在nginx源码目录下的configure选项中加入--with-http_v2_module,由于HTTP2需要SSL的支持,因此如缺少--with-http_ssl_module选项,还需要加入--with-http_ssl_module。
如下:
./configure --with-pcre=/usr/local/src/pcre-8.40 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.1.0e \
--add-module=/usr/local/src/nginx_modules_demo/ngx_http_mytest_module \
--with-http_ssl_module \
--with-threads \
--with-http_v2_module \
--with-debug
make
make install
注意:中途增加第三方模块并重新编译安装nginx,原有/usr/local/nginx/conf下面的文件并不会覆盖
配置ssl证书
调研了一下申请免费证书的基本步骤,发现首先需要注册一个合法域名,dns可以解析到这个域名,才能针对这个域名申请证书。
这个对于只做demo的我来说,比较难办。于是我找到一个讨巧的方法,直接去公司线上找一个小文件的服务域名的证书和私钥,配置在本地测试服务器上。
过程略。
比如说,这个域名是www.xyaz.cn,它的服务器证书和私钥分别记为server.crt和server.key文件。
下面配置nginx.conf,得到
检查nginx配置是否正确?
/usr/local/nginx/sbin/nginx -t
编译带有http2功能的curl作为本地测试客户端
http://blog.csdn.net/tao_627/article/details/77263080
测试nginx的http2功能
vim /etc/hosts
添加-行
127.0.0.1 www.xyaz.cn
本地测试
curl --http2 -vo test.out https://www.xyaz.cn/
参考文献
http://www.cnblogs.com/bugutian/p/6628455.html
回见
http://blog.csdn.net/tao_627/article/details/60957521
在nginx源码目录下的configure选项中加入--with-http_v2_module,由于HTTP2需要SSL的支持,因此如缺少--with-http_ssl_module选项,还需要加入--with-http_ssl_module。
如下:
./configure --with-pcre=/usr/local/src/pcre-8.40 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.1.0e \
--add-module=/usr/local/src/nginx_modules_demo/ngx_http_mytest_module \
--with-http_ssl_module \
--with-threads \
--with-http_v2_module \
--with-debug
make
make install
注意:中途增加第三方模块并重新编译安装nginx,原有/usr/local/nginx/conf下面的文件并不会覆盖
配置ssl证书
调研了一下申请免费证书的基本步骤,发现首先需要注册一个合法域名,dns可以解析到这个域名,才能针对这个域名申请证书。
这个对于只做demo的我来说,比较难办。于是我找到一个讨巧的方法,直接去公司线上找一个小文件的服务域名的证书和私钥,配置在本地测试服务器上。
过程略。
比如说,这个域名是www.xyaz.cn,它的服务器证书和私钥分别记为server.crt和server.key文件。
下面配置nginx.conf,得到
# HTTPS server server { listen 443 ssl http2 default_server; server_name localhost; ssl on; ssl_certificate /usr/local/nginx/conf/server.crt; ssl_certificate_key /usr/local/nginx/conf/server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } }
检查nginx配置是否正确?
/usr/local/nginx/sbin/nginx -t
编译带有http2功能的curl作为本地测试客户端
http://blog.csdn.net/tao_627/article/details/77263080
测试nginx的http2功能
vim /etc/hosts
添加-行
127.0.0.1 www.xyaz.cn
本地测试
curl --http2 -vo test.out https://www.xyaz.cn/
参考文献
http://www.cnblogs.com/bugutian/p/6628455.html
相关文章推荐
- 在CentOS 6.9 x86_64的nginx 1.12.2上开启标准模块ngx_http_auth_request_module实录
- 在CentOS 6.8 x86_64上安装nginx 1.10.3
- 在CentOS 6.9 x86_64的nginx 1.12.2上开启ngx_http_geo_module模块实录
- 在CentOS 6.9 x86_64上开启nginx 1.12.2的stub_status模块(ngx_http_stub_status_module)监控
- 在CentOS 6.9 x86_64的nginx 1.12.2上开启ngx_http_empty_gif_module模块实录
- 在CentOS 6.9 x86_64的nginx 1.12.2上开启标准模块ngx_http_map_module实录
- 在CentOS 6.9 x86_64的nginx 1.12.2上开启echo-nginx-module模块实录
- 在CentOS 6.8 x86_64上安装nghttp2最新版及让curl具有http2特性
- 在CentOS 6.9 x86_64的nginx 1.12.2上开启ngx_req_status模块实录
- CentOS 6.4 x86_64 部署 nginx 服务器实现点播功能
- 在CentOS 6.8 x86_64上安装nghttp2最新版及让curl具有http2特性
- 在CentOS 6.9 x86_64上开启nginx 1.12.2的proxy_cache缓存配置
- NGINX轻松管理10万长连接 --- 基于2GB内存的CentOS 6.5 x86-64
- CentOS 6.3安装Nginx开启目录浏览、下载功能
- centos6.5_x86_64 下 nginx 1.10.1、php7 安装记录
- CentOS 6.3安装Nginx开启目录浏览、下载功能
- centos6.4-x86-64系统更新系统自带Apache Http Server
- centos6.4-x86-64系统更新系统自带Apache Http Server
- NGINX轻松管理10万长连接 --- 基于2GB内存的CentOS 6.5 x86-64