WEB application

Solve the problem that the Nginx configuration of http2 does not work, and Google Browser still uses the http1.1 protocol

Jager · November 11 · 2016 · · · 2574 times read

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. Solve the problem that the Nginx configuration of http2 does not work, and Google Browser still uses the http1.1 protocol

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:

 Solve the problem that the Nginx configuration of http2 does not work, and Google Browser still uses the http1.1 protocol

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!

30 responses
  1. Looking forward to Licoy 2016-11-12 · 11:20

    No wonder I configured http2 before, and the protocol of http1.1 is still used when accessing.

  2. Online earning 2016-11-13 · 11:14

    Not bad, thanks for sharing

  3. Inspirational Quotes 2016-11-14 · 10:17

    Sign in successfully! Sign in time: 10:16:36 am, sign in every day, and life will be more exciting~

  4. Songsong soft text 2016-11-14 · 10:36

    Thanks for sharing

  5. Shopping Street 2016-11-15 · 17:55

    Thanks for sharing

  6. Easy task 2016-11-16 · 15:00

    Sofa~+1

  7. LOL practice 2016-11-17 · 13:57

    The space doesn't know whether it supports or not

  8. aunsen 2016-11-17 · 15:12

    Does Jager have any recommendation from the Windows host? Recently, an asp.net station will be launched

    •  avatar
      Jager 2016-11-17 · 16:10

      I have never used win.. Not good to recommend..

  9. Wang Jianjian 2016-11-17 · 15:40

    Worship the technology emperor

  10. Return to Hi Rebate 2016-11-17 · 17:58

    The blogger shares dry goods here

  11. Songsong soft text 2016-11-18 · 8:51

    Not used

  12. themebetter 2016-11-18 · 9:57

    It is important to keep records at all times.

  13. Mobile Frog ranking software 2016-11-18 · 16:16

    Google Browser http1.1 is OK, so you don't need to change it

  14. Sen Qi 2016-11-18 · 16:41

    Good article

  15. Xiaocan Blog 2016-11-20 · 13:38

    At present, the CDN service of Tencent Cloud does not support http 2.0 The CDN using Tencent Cloud is not displayed after the source station has configured it.

  16. Fruit pit net 2016-11-20 · 16:05

    Sign in successfully! Sign in time: 4:04:13 p.m., sign in every day, and life is more exciting~

  17. Enterprise consulting 2016-11-22 · 12:29

    This is good to share

  18. Mother baby B2B 2016-11-22 · 13:58

    Thanks for sharing!

  19. Brother, earn blog online 2016-11-22 · 14:41

    Bad writing is better than good memory

  20. Easy task 2016-11-23 · 13:30

    Laugh and cry, no record to rebuild the wheel

  21. Https is the trend of future workstations.

  22. Teacher Hu Yang 2016-12-2 · 18:50

    The code is always looked at for a long time, but still not

  23. Reten 2016-12-3 · 22:27

    How to set the N+A environment.

    •  avatar
      Jager 2016-12-5 · 9:25

      N+A N is the outermost layer, and this article is still valid.

  24. Hcyc 2016-12-30 · 2:26

    SPDY Protocol Not Enabled!
    Seriously? This SSL/TLS server is using the NPN Entension to tell browsers it supports alternative protocols, but SPDY is not a protocol it supports. The server is not making SPDY an option. Since all the pieces are in place, hopefully it will be easy to enable SPDY support with this server.

    Well done, the website has not changed. Baidu's answer to the test is wrong.

  25. Xiaochao 2017-1-19 · 13:02

    Hello, blogger Jager, I want to ask whether the server has any configuration that can prevent DDOS attacks. These days, the server has been attacked for half an hour continuously, which has exceeded the peak value of free anti DDOS attacks of Alibaba Cloud. The website and server cannot be opened for half an hour. What precautions do you have?

  26. Xiaochao 2017-2-20 · 19:32

    Hello, Jager blogger. I remember in June 2016, when I configured http2.0, I found that the collection changes were too unstable. One was more than 1000, the other was 300. I was a little confused. What was wrong

  27. Broken Lord 2017-3-10 · 17:36

    Https has not been activated. You have all started to play http2..

  28. abcdocker 2017-3-31 · 19:10

    The article is good, like it!