Yesterday, a netizen contacted me through QQ and said that the http2 configuration tutorial shared by my blog before could not take effect. He wanted me to help him take a look.
After testing, using Google Browser to access his test site, it is true that http2 is not enabled, but his configuration and compilation parameters are correct, which is a bit strange.
However, he was too busy yesterday to continue to help him analyze, so he had to leave a message to me with the server account and password. At noon today, I took the time to recompile and test one on his server, and found it was such a problem!
Before compiling Nginx, he used the openssl installed by yum. Maybe his yum source was too old, or the version of openssl installed by yum was too low because he did not configure EPEL! However, when compiling Nginx, he did not use the option of -- with openssl=DIR to compile statically, so the lower version openssl of the system he compiled for Nginx does not enable http2 when Google accesses it!
Find a professional to explain as follows:
Chrome gave up its support for NPN in the latest update. If you want to continue supporting HTTP/2 on Chrome, you need to install the latest version 1.0.2 of OpenSSL, and recompile Nginx with OpenSSL 1.0.2.
reference material:
New Chrome Scroll Back to HTTP/1.1
Supporting HTTP/2 for Google Chrome Users
Therefore, the solution is very simple Openssl official website Download the latest source code package, add the following parameters and recompile:
--With openssl=Source package decompression directory
For example:
./configure --prefix=/usr/local/ nginx --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-openssl=/data/openssl-1.0.2c
Of course, we can also update the yum source first, for example, use the EPEL source instead, and use yum update openssl to upgrade and recompile. Here I personally suggest using static compilation of source code.
After recompiling and installing, use Google Browser to visit the following website:
chrome://net-internals/#http2
Testing his website has successfully opened http2:
Later, it suddenly occurred to me that I had encountered the same problem when I was tossing about the website before, because there was no record, which led to repeated creation of wheels. So let's share the record this time. Let's consider it as a memo!