Home > Article > Backend Development > nginx http2 configuration
HTTP 2.0, Hypertext Transfer Protocol 2.0, is the next generation of HTTP protocol. It was developed by the Hypertext Transfer Protocol Bis (httpbis) working group of the Internet Engineering Task Force (IETF). It is the first update since http1.1 was released in 1999.
The HTTP/2 protocol evolved from SPDY. SPDY has completed its mission and will soon withdraw from the stage of history (for example, Chrome will end support for SPDY in early 2016); Nginx and Apache have also fully supported HTTP/2 , and SPDY is no longer supported).
Generally, everyone refers to HTTP2 as h2. Although some friends may not be willing to do so, this abbreviation has become the default, especially since browsers use this abbreviation for HTTP2.
1: Installation of nginx
http2 requires ssl support. The required software packages are as follows
nginx-1.9.12.tar.gz
openssl-1.0.1s.tar.gz
pcre-8.38.zip
zlib- 1.2.8.tar.gz
The default compiled nginx does not include the http2 module. So when compiling nginx, you need to enable at least the two modules http_v2_module and http_ssl_module
./configure --prefix=/usr/local/nginx --with-zlib=/tmp/2/zlib-1.2.8 --with-pcre=/tmp/2/pcre-8.38 --with-http_v2_module --with-http_ssl_module --with-openssl=/tmp/2/openssl-1.0.1s
Then
make
make install
Two: Use openssl to create an SSL certificate
Reference: http://blog.csdn.net/mn960mn/article/details/42374597
Three: nginx configuration
server { listen 443 ssl http2; server_name http2.yuni.com; ssl_certificate /usr/local/nginx/ssl/server.crt; ssl_certificate_key /usr/local/nginx/ssl/server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers off; location / { root html; index index.html index.htm; } }
Four: Test
It is best to use the latest versions of chrome and firefox browsers. I use chrome v49 here
Configure http2.yuni.com in local hosts to point to the nginx IP address
Then, visit https://http2 .yuni.com Note, be sure to use https
to view nginx’s access.log log
The above introduces the nginx http2 configuration, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.