首页
首页

解决nginx配置http2无效问题

解决nginx配置http2无效

其实这篇文章名称叫做openssl升级会更好。

在上一篇文章nginx 1.8.1 升级至 1.10.3,并启用http2说道在nginx中启用http2协议,

根据文章做好之后发现,还是无法使用http2协议。

google、百度排查 问题为:

Chrome 在最近的更新中放弃了对 NPN 的支持,如果想要继续在 Chrome 上支持 HTTP/2 ,则需要安装高于 1.0.2 版的 OpenSSL,并且使用新版本的 OpenSSL 重新编译 Nginx。

我这里使用的版本是最新版本,1.1.0e, openssl-1.1.0e点击下载

本文思路:

a. 升级openssl
b. 重新编译nginx

这里主要说如何升级openssl,重新编译nginx请看nginx 1.8.1 升级至 1.10.3,并启用http2

1、下载

# wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz  && tar zxf openssl-1.1.0e.tar.gz

2、编译

#./config shared zlib
#make && make install

3、备份替换升级

1
2
3
4
5
#mv /usr/bin/openssl /usr/bin/openssl.old
#mv /usr/include/openssl /usr/include/openssl.old
#cp apps/openssl /usr/bin/
#echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
#ldconfig -v

4、检查

#openssl version
OpenSSL 1.1.0e 16 Feb 2017

5、重新编译nginx并检查

1
2
3
4
5
6
7
8
 #nginx -V 

[root@www ~]# nginx -V
nginx version: nginx/1.10.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.1.0e 16 Feb 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --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-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --add-module=/git/ngx_http_substitutions_filter_module --with-http_v2_module --with-openssl=/git/openssl-1.1.0e
built with OpenSSL 1.1.0e 发现存在该文本内容即可。

以上

感谢你浪费时间观看本篇文章,希望此文章对你有帮助。

End!

支持一下
扫一扫,我会更有动力更新
  • 微信扫一扫
  • 支付宝扫一扫