尊龙凯时人生就是搏

Nginx HTTP2ÉèÖý̳̣¬ÌáÉýÍøÕ¾»á¼ûËÙÂÊ

nginx http2ÉèÖý̳̣¬ÌáÉýÍøÕ¾»á¼ûËÙÂÊ

¸ÅÊö£º

ÔÚÏÖ´ú»¥ÁªÍøÖУ¬¿ìËÙµÄÍøÕ¾¼ÓÔØËÙÂÊÊÇÎüÒýÓû§µÄÒªº¦ÒªËØÖ®Ò»¡£HTTP/2ÊÇÒ»ÖÖÐÂÒ»´úµÄÍøÂçͨѶЭÒ飬Ëüͨ¹ýÓÅ»¯Êý¾Ý´«ÊäµÄ·½·¨£¬Ê¹µÃÍøÕ¾µÄ¼ÓÔØËÙÂʸü¿ì¡¢ÐÔÄܸü¼Ñ¡£±¾½Ì³Ì½«Ö¸µ¼ÄúÔõÑùʹÓÃNginxЧÀÍÆ÷¾ÙÐÐHTTP/2µÄÉèÖ㬴ӶøÌáÉýÍøÕ¾µÄ»á¼ûËÙÂÊ¡£

°ì·¨Ò»£º×°ÖÃNginx

Ê×ÏÈ£¬ÔÚÄúµÄЧÀÍÆ÷ÉÏ×°ÖÃNginx¡£Æ¾Ö¤ÄúʹÓõIJÙ×÷ϵͳ²î±ð£¬¿ÉÒԲο¼ÏìÓ¦µÄÎĵµ¾ÙÐÐ×°Öá£

°ì·¨¶þ£ºÌìÉúSSLÖ¤Êé

ΪÁËʹÓÃHTTP/2£¬ÄúÐèҪΪÄúµÄÍøÕ¾ÌìÉúÒ»¸öSSLÖ¤Êé¡£Äú¿ÉÒÔʹÓÃLet’s EncryptµÈÃâ·ÑµÄSSLÖ¤Êé½ÒÏþ»ú¹¹£¬Ò²¿ÉÒÔ¹ºÖÃÉÌÒµSSLÖ¤Êé¡£

°ì·¨Èý£ºÉèÖÃNginx

ÕÒµ½ÄúµÄNginxÉèÖÃÎļþ£¬Í¨³£Î»ÓÚ/etc/nginx/nginx.conf»ò/etc/nginx/sites-available/default¡£ÔÚ¸ÃÎļþÖоÙÐÐÈçÏÂÉèÖãº

¿ªÆôHTTP/2Ö§³Ö

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

http {

listen 443 ssl http2;
ssl_certificate /path/to/your/ssl/certificate.crt;
ssl_certificate_key /path/to/your/ssl/private.key;

...

µÇ¼ºó¸´ÖÆ

}

ÉèÖüÓÃÜÌ×¼þ

ÔÚssl_protocolsºÍssl_ciphersÖÐÌí¼ÓÒÔÏÂÉèÖãº

http {

...
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

...

µÇ¼ºó¸´ÖÆ

}

ÆôÓÃgzipѹËõ

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

server {

...
gzip on;
gzip_types text/plain text/css application/javascript image/svg+xml;

...

µÇ¼ºó¸´ÖÆ

}

ÉèÖûº´æ

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

server {

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

...

µÇ¼ºó¸´ÖÆ

}

ÉèÖÃÖض¨ÏòHTTPµ½HTTPS

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

server {

...
listen 80;
server_name yourdomain.com;
return 301 https://yourdomain.com$request_uri;

...

µÇ¼ºó¸´ÖÆ

}

ÖØÆôNginx

ÔÚÍê³ÉÒÔÉÏÉèÖúó£¬ÉúÑÄNginxÉèÖÃÎļþ£¬²¢ÖØÐÂÆô¶¯NginxЧÀÍ¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

sudo nginx -t # ¼ì²éÉèÖÃÎļþÊÇ·ñÓÐÓï·¨¹ýʧ

sudo systemctl restart nginx # ÖØÆôNginxЧÀÍ

°ì·¨ËÄ£º²âÊÔHTTP/2

ͨ¹ýä¯ÀÀÆ÷»á¼ûÄúµÄÍøÕ¾£¬²¢·­¿ªä¯ÀÀÆ÷µÄ¿ª·¢Õß¹¤¾ß¡£ÔÚ”Network”Ñ¡ÏÖУ¬¼ì²éHTTP°æ±¾ÊÇ·ñΪHTTP/2¡£

´úÂëʾÀý£º

ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄNginxÉèÖÃʾÀý£¬¹©²Î¿¼£º

http {

server {
    listen       443 ssl http2;
    server_name  yourdomain.com;

    ssl_certificate      /path/to/your/ssl/certificate.crt;
    ssl_certificate_key  /path/to/your/ssl/private.key;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    
    location ~* .(jpg|jpeg|gif|png|css|js)$ {
        expires 1y;
        add_header Cache-Control "public";
    }
}

µÇ¼ºó¸´ÖÆ

}

½áÂÛ£º

ͨ¹ýÔÚNginxÖÐÆôÓÃHTTP/2£¬²¢¾ÙÐÐһЩÓÅ»¯ÉèÖã¬Äܹ»ÏÔ×ÅÌáÉýÄúÍøÕ¾µÄ»á¼ûËÙÂÊ¡£Í¬Ê±£¬»¹¿ÉÒÔÉèÖûº´æ¡¢ÆôÓÃgzipѹËõµÈ£¬½øÒ»²½¸ÄÉÆÓû§µÄ»á¼ûÌåÑ顣ϣÍû±¾½Ì³Ì¶ÔÄúÓÐËù×ÊÖú£¬×£ÄúµÄÍøÕ¾¸ü¿ì¡¢¸üÁ÷ͨ£¡

ÒÔÉϾÍÊÇNginx HTTP2ÉèÖý̳̣¬ÌáÉýÍøÕ¾»á¼ûËÙÂʵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ