Nginx¿ªÆôHTTP/2ÉèÖ㬼ÓËÙÍøÕ¾»á¼ûËÙÂÊ
nginx¿ªÆôhttp/2ÉèÖ㬼ÓËÙÍøÕ¾»á¼ûËÙÂÊ
ͻ񻣼
Ëæ×Å»¥ÁªÍøµÄѸÃÍÉú³¤£¬ÍøÕ¾µÄ»á¼ûËÙÂʳÉΪÓû§ÌåÑéµÄÖ÷ÒªÒòËØÖ®Ò»¡£HTTP/2ÊÇÒ»ÖÖеÄÍøÂçÐÒ飬¿ÉÒÔÓÐÓõØÌá¸ßÍøÕ¾µÄ¼ÓÔØËÙÂʺÍÐÔÄÜ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚNginxÉÏ¿ªÆôHTTP/2ÉèÖ㬴Ӷø¼ÓËÙÍøÕ¾µÄ»á¼ûËÙÂÊ¡£
×°ÖÃNginx
Ê×ÏÈ£¬ÐèҪȷ±£ÒѾװÖÃÁËNginx¡£ÔÚUbuntuϵͳÉÏ£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´×°ÖÃNginx£º
$ sudo apt-get update $ sudo apt-get install nginx
µÇ¼ºó¸´ÖÆ
ÔÚ×°ÖÃÍê³Éºó£¬Í¨¹ýÒÔÏÂÏÂÁîÀ´ÑéÖ¤NginxÊÇ·ñÒѾÀÖ³É×°Öãº
$ nginx -v
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
¼ì²éNginxÊÇ·ñÖ§³ÖHTTP/2
ÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁ
$ nginx -v
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÔÚÊä³öÐÅÏ¢ÖУ¬¿ÉÒÔÉó²éÊÇ·ñ°üÀ¨ÁË–with-http_v2_module£¬ÈôÊDZ£´æÔòÌåÏÖNginxÒѾ֧³ÖHTTP/2£¬²»È»ÐèÒªÖØбàÒëNginx»òÕß×°ÖÃÖ§³ÖHTTP/2µÄ°æ±¾¡£
ÐÞ¸ÄNginxÉèÖÃÎļþ
ÔÚ½«ÉèÖÃÎļþÐÞ¸ÄÇ°£¬¿ÉÒÔÏȱ¸·ÝÄ¿½ñµÄÉèÖÃÎļþ¡£ÉèÖÃÎļþͨ³£Î»ÓÚ/etc/nginx/nginx.conf»òÕß/etc/nginx/conf.d/default.conf¡£
·¿ªÉèÖÃÎļþ£¬²¢ÕÒµ½server²¿·Ö£¬Ìí¼ÓÒÔÏÂÉèÖãº
listen 443 ssl http2; ssl_certificate /path/to/your/certificate.pem; ssl_certificate_key /path/to/your/private_key.pem;
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬/path/to/your/certificate.pemºÍ/path/to/your/private_key.pemÐèÒªÌæ»»³ÉÄãµÄSSLÖ¤ÊéºÍ˽ԿµÄ·¾¶¡£
ÖØмÓÔØNginxÉèÖÃ
ÉúÑÄÉèÖÃÎļþºó£¬Ö´ÐÐÒÔÏÂÏÂÁîÀ´ÖØмÓÔØNginxÉèÖãº
$ sudo service nginx restart
µÇ¼ºó¸´ÖÆ
ÈôÊÇÉèÖÃÎļþÖÐûÓйýʧ£¬Nginx½«»áÖØмÓÔØÉèÖò¢ÆôÓÃHTTP/2¡£
Ä¥Á·HTTP/2ÊÇ·ñÉúЧ
¿ÉÒÔʹÓÃÒÔÏÂÍøÕ¾»ò¹¤¾ßÀ´ÑéÖ¤ÊÇ·ñÀֳɿªÆôÁËHTTP/2£º
https://tools.keycdn.com/http2-test
https://www.ssllabs.com/ssltest/
ÔÚÑé֤Ч¹ûÖУ¬¿ÉÒÔÉó²éµ½HTTP/2ÊÇ·ñÀֳɿªÆô¡£
×ܽ᣺
±¾ÎÄÏÈÈÝÁËÔÚNginxÉÏ¿ªÆôHTTP/2ÉèÖõİ취£¬²¢¸½ÉÏÁËÏà¹ØµÄ´úÂëʾÀý¡£HTTP/2×÷ΪһÖÖеÄÍøÂçÐÒ飬¿ÉÒÔÓÐÓõØÌá¸ßÍøÕ¾µÄ¼ÓÔØËÙÂʺÍÐÔÄÜ¡£Í¨¹ýÉèÖÃNginx£¬¿ÉÒÔÈÃÍøÕ¾¸ü¿ìµØ¼ÓÔز¢ÌáÉýÓû§ÌåÑ顣ϣÍû±¾ÎÄÄܶÔÄãÔÚNginxÉÏ¿ªÆôHTTP/2ÉèÖÃÓÐËù×ÊÖú¡£
²Î¿¼ÎÄÏ×£º
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-with-http-2-support-on-ubuntu-16-04
https://www.nginx.com/blog/nginx-1-9-5/
https://www.nginx.com/blog/http2-module-nginx/
ÒÔÉϾÍÊÇNginx¿ªÆôHTTP/2ÉèÖ㬼ÓËÙÍøÕ¾»á¼ûËÙÂʵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡