×ðÁú¿­Ê±¹ÙÍøµÇ¼

NginxЧÀÍÆ÷µÄHTTP/2ЭÒéÖ§³ÖºÍÐÔÄÜÌáÉý¼¼ÇÉÏÈÈÝ

NginxЧÀÍÆ÷µÄHTTP/2ЭÒéÖ§³ÖºÍÐÔÄÜÌáÉý¼¼ÇÉÏÈÈÝ

СÐò£º

Ëæ×Å»¥ÁªÍøµÄ¿ìËÙÉú³¤ £¬ÈËÃǶÔÍøÕ¾ËÙÂʵÄÒªÇóÔ½À´Ô½¸ß¡£ÎªÁËÌṩ¸ü¿ìµÄÍøÕ¾ÏìÓ¦ËÙÂʺ͸üºÃµÄÓû§ÌåÑé £¬NginxЧÀÍÆ÷µÄHTTP/2ЭÒéÖ§³ÖºÍÐÔÄÜÌáÉý¼¼ÇɱäµÃÖÁ¹ØÖ÷Òª¡£±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃNginxЧÀÍÆ÷ÒÔÖ§³ÖHTTP/2ЭÒé £¬²¢ÌṩһЩÐÔÄÜÌáÉýµÄ¼¼ÇÉ¡£

Ò»¡¢HTTP/2ЭÒé¼ò½é£º

HTTP/2ЭÒéÊÇHTTPЭÒéµÄÏÂÒ»´ú±ê×¼ £¬ËüÔÚ´«Êä²ãʹÓöþ½øÖÆÃûÌþÙÐÐÊý¾Ý´«Êä £¬Ïà±È֮ǰµÄHTTP1.xЭÒé £¬HTTP/2ЭÒé¾ßÓиüµÍµÄÑӳٺ͸ü¸ßµÄ²¢·¢´«ÊäÄÜÁ¦¡£Í¨¹ýʹÓÃHTTP/2ЭÒé £¬¿ÉÒÔÏÔÖøÌá¸ßÍøÕ¾µÄ¼ÓÔØËÙÂʺÍÐÔÄÜ¡£

¶þ¡¢ÉèÖÃNginxЧÀÍÆ÷Ö§³ÖHTTP/2ЭÒ飺

×°ÖÃNginx£º

Ê×ÏÈÐèҪȷ±£ÒѾ­×°ÖÃÁËNginxЧÀÍÆ÷¡£ÈôÊÇÉÐδװÖà £¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº

sudo apt-get update
sudo apt-get install nginx

µÇ¼ºó¸´ÖÆ

ÉèÖÃNginxÖ§³ÖHTTP/2ЭÒ飺

ÕÒµ½NginxµÄÉèÖÃÎļþ £¬Ä¬ÈÏ·¾¶Îª/etc/nginx/nginx.conf £¬Ê¹ÓÃÎı¾±à¼­Æ÷·­¿ª¡£

sudo nano /etc/nginx/nginx.conf

µÇ¼ºó¸´ÖÆ

ÔÚhttp¿éÖÐÌí¼ÓÒÔÏÂÉèÖãº

http {
    ...
    listen 443 ssl http2;
    ssl_certificate /etc/ssl/certs/nginx.crt;
    ssl_certificate_key /etc/ssl/private/nginx.key;
    ...
}

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬listen 443 ssl http2ÌåÏÖʹÓÃHTTPSЭæźÍHTTP/2ЭÒé¾ÙÐмàÌý¡£ssl_certificateºÍssl_certificate_keyÖ¸¶¨ÁËSSLÖ¤ÊéºÍ˽ԿµÄ·¾¶¡£È·±£½«×¼È·ÉèÖÃÖ¤ÊéºÍ˽ԿµÄ·¾¶¡£

ÖØÆôNginxЧÀÍÆ÷£º

Íê³ÉÉèÖúó £¬ÐèÖØÆôNginxЧÀÍÆ÷ÒÔʹÉèÖÃÉúЧ¡£

sudo service nginx restart

µÇ¼ºó¸´ÖÆ

Èý¡¢ÐÔÄÜÌáÉýµÄ¼¼ÇÉ£º

³ýÁËÉèÖÃÖ§³ÖHTTP/2ЭÒéÍâ £¬ÎÒÃÇ»¹¿ÉÒÔʹÓÃһЩ¼¼ÇÉÀ´½øÒ»²½ÌáÉýNginxЧÀÍÆ÷µÄÐÔÄÜ¡£

ÆôÓÃGzipѹËõ£º

¿ªÆôGzipѹËõ¿ÉÒÔïÔÌ­´«ÊäÊý¾ÝÁ¿ £¬¼ÓËÙÍøÕ¾µÄ¼ÓÔØËÙÂÊ¡£ÔÚNginxÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÉèÖãº

http {
    ...
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml;
    ...
}

µÇ¼ºó¸´ÖÆ

gzip onÌåÏÖÆôÓÃGzipѹËõ¡£gzip_typesÖ¸¶¨ÁËҪѹËõµÄÎļþÀàÐÍ¡£

ÉèÖþ²Ì¬×ÊÔ´»º´æ£º

¹ØÓÚ¾²Ì¬×ÊÔ´Îļþ £¬¿ÉÒÔ¾ÙÐлº´æÒÔïÔ̭ЧÀÍÆ÷µÄ¸ºÔØ¡£ÔÚNginxÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÉèÖãº

http {
    ...
    location ~* .(css|js|png|jpg|jpeg|gif|ico)$ {
        expires 1y;
        add_header Cache-Control "public";
    }
    ...
}

µÇ¼ºó¸´ÖÆ

Õâ¶ÎÉèÖÃÌåÏÖ¶ÔÒ»ÄêÄÚ²»»á¸Ä±äµÄ¾²Ì¬×ÊÔ´Îļþ¾ÙÐлº´æ¡£

ÆôÓÃKeep-AliveÅþÁ¬£º

Keep-AliveÅþÁ¬Ê¹ä¯ÀÀÆ÷ºÍЧÀÍÆ÷Ö®¼ä¿ÉÒÔ¶à´Î·¢ËÍÇëÇóºÍÏìÓ¦ £¬×èÖ¹ÁËÿ´ÎÇëÇ󶼽¨ÉèеÄÅþÁ¬ £¬ïÔÌ­ÁËÑÓ³ÙºÍÅþÁ¬½¨ÉèµÄ¿ªÏú¡£ÔÚNginxµÄÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÉèÖãº

http {
    ...
    keepalive_timeout 65;
    ...
}

µÇ¼ºó¸´ÖÆ

keepalive_timeoutÌåÏÖKeep-AliveÅþÁ¬µÄ³¬Ê±Ê±¼ä £¬Ò»Ñùƽ³£ÉèΪ60Ãë¡£

¿¢ÊÂÓ

±¾ÎÄÏÈÈÝÁËÔõÑùÉèÖÃNginxЧÀÍÆ÷ÒÔÖ§³ÖHTTP/2ЭÒé £¬²¢ÌṩÁËһЩÐÔÄÜÌáÉýµÄ¼¼ÇÉ £¬°üÀ¨ÆôÓÃGzipѹËõ¡¢ÉèÖþ²Ì¬×ÊÔ´»º´æºÍÆôÓÃKeep-AliveÅþÁ¬¡£Í¨¹ýºÏÀíÉèÖúÍÓÅ»¯ £¬¿ÉÒÔÏÔÖøÌáÉýNginxЧÀÍÆ÷µÄÐÔÄܺÍÏìÓ¦ËÙÂÊ £¬Ìṩ¸üºÃµÄÓû§ÌåÑ顣ϣÍû±¾ÎĶÔÄãÃ÷È·ºÍÓ¦ÓÃNginxЧÀÍÆ÷µÄHTTP/2ЭÒéÓëÐÔÄÜÌáÉý¼¼ÇÉÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇNginxЧÀÍÆ÷µÄHTTP/2ЭÒéÖ§³ÖºÍÐÔÄÜÌáÉý¼¼ÇÉÏÈÈݵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ