尊龙凯时人生就是搏

ÔõÑùʹÓÃNginxʵÏÖHTTP/2ЭÒéÖ§³Ö

ÔõÑùʹÓÃnginxʵÏÖhttp/2ЭÒéÖ§³Ö

¸ÅÊö£º

HTTP/2ÊÇÒ»ÖÖÐÂÒ»´úµÄHTTPЭÒ飬Ïà±È֮ǰµÄHTTP/1.xЭÒ飬ËüÔÚÐÔÄܺÍЧÂÊÉÏÓÐÁ˺ܴóµÄÌáÉý¡£ÎªÁËÖ§³ÖHTTP/2ЭÒ飬ÎÒÃÇ¿ÉÒÔʹÓÃNginx×÷ΪHTTPЧÀÍÆ÷£¬²¢ÉèÖÃÏìÓ¦µÄÉèÖá£

×°ÖúÍÉèÖÃNginx£º

Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃNginx¡ £¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÔÚUbuntuϵͳÖоÙÐÐ×°Öãº

sudo apt-get update
sudo apt-get install nginx

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó£¬ÎÒÃÇÐèÒªÉèÖÃNginxÒÔÖ§³ÖHTTP/2ЭÒé¡£·­¿ªNginxµÄÉèÖÃÎļþ£¬¿ÉÒÔÔÚÒÔÏÂλÖÃÕÒµ½£º

sudo nano /etc/nginx/nginx.conf

µÇ¼ºó¸´ÖÆ

ÕÒµ½server¿éÖеÄlistenÖ¸Á²¢Ìí¼Óhttp2×÷Ϊ²ÎÊý£¬ÈçÏÂËùʾ£º

server {
    listen 443 ssl http2;
    ...
}

µÇ¼ºó¸´ÖÆ

×¢ÖØ£¬ÕâÀï¼ÙÉèÄúµÄÍøվʹÓÃÁËSSLÖ¤ÊéÇÒʹÓÃĬÈϵÄ443¶Ë¿Ú¡£ÈôÊÇÄúµÄÍøվûÓÐÆôÓÃSSL»òʹÓòî±ðµÄ¶Ë¿Ú£¬ÇëÏìÓ¦µØµ÷½âÉèÖá£

ÉúÑIJ¢¹Ø±ÕÎļþºó£¬ÖØÐÂÆô¶¯NginxÒÔʹ¸ü¸ÄÉúЧ£º

sudo systemctl restart nginx

µÇ¼ºó¸´ÖÆ

ÉèÖÃSSLÖ¤Ê飺

ΪÁËʹÓÃHTTP/2ЭÒ飬ÎÒÃÇÐèÒªÉèÖÃSSLÖ¤Êé¡£ÔÚ´ËʾÀýÖУ¬ÎÒÃǽ«Ê¹ÓÃ×ÔÊðÃûÖ¤Êé¡£ÔÚÉú²úÇéÐÎÖУ¬Ó¦Ê¹ÓÃÊÜÐÅÍеÄÖ¤Êé½ÒÏþ»ú¹¹ÊðÃûµÄÖ¤Êé¡£

Ê×ÏÈ£¬½¨ÉèÒ»¸öÓÃÓÚ´æ´¢SSLÖ¤ÊéµÄĿ¼£º

sudo mkdir /etc/nginx/ssl

µÇ¼ºó¸´ÖÆ

È»ºó£¬ÌìÉú˽ԿºÍÖ¤ÊéÇëÇó£º

sudo openssl req -new -newkey rsa:2048 -nodes -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.csr

µÇ¼ºó¸´ÖÆ

ƾ֤ÌáÐѾÙÐÐÏà¹ØÐÅÏ¢µÄÌîд£¬ÀýÈç¹ú¼ÒÂë¡¢×éÖ¯Ãû³ÆµÈ¡£

½ÓÏÂÀ´£¬×ÔÊðÃûÖ¤Ê飺

sudo openssl x509 -req -days 365 -in /etc/nginx/ssl/nginx.csr -signkey /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt

µÇ¼ºó¸´ÖÆ

ÉèÖÃNginxÒÔʹÓÃSSLÖ¤Êé¡£·­¿ªNginxµÄÉèÖÃÎļþ£¬²¢ÕÒµ½ÒÔÏÂÐУº

server {
    ...
    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    ...
}

µÇ¼ºó¸´ÖÆ

×÷·Ï×¢ÊÍlistenÖ¸ÁͬʱÌí¼ÓSSLÖ¤ÊéµÄ·¾¶ºÍ˽ԿµÄ·¾¶£º

server {
    ...
    # SSL configuration
    #
    listen 443 ssl http2;
    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;
    ...
}

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢¹Ø±ÕÎļþºó£¬ÖØÐÂÆô¶¯NginxÒÔʹ¸ü¸ÄÉúЧ¡£

²âÊÔHTTP/2ЭÒéÖ§³Ö£º

ΪÁËÑéÖ¤ÊÇ·ñÀÖ³ÉÆôÓÃÁËHTTP/2ЭÒ飬Çë·­¿ªä¯ÀÀÆ÷²¢»á¼ûÄúµÄÍøÕ¾¡£ÔÚä¯ÀÀÆ÷µÄ¿ª·¢Õß¹¤¾ßÖУ¬Éó²éNetworkÑ¡Ï£¬¿ÉÒÔ¿´µ½ÇëÇóµÄЭÒéΪHTTP/2¡£

´úÂëʾÀý£º

ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄNginxÉèÖÃʾÀý£¬ÆäÖаüÀ¨ÁËHTTP/2ЭÒéµÄÖ§³Ö£º

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

    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

    location / {
        root /var/www/html;
        index index.html;
    }
}

µÇ¼ºó¸´ÖÆ

½áÂÛ£º

ͨ¹ýʹÓÃNginxÉèÖÃÖ§³ÖHTTP/2ЭÒ飬ÎÒÃÇÄܹ»ÌáÉýÍøÕ¾µÄÐÔÄܺÍЧÂÊ¡£Í¨¹ý×ñÕÕ±¾ÎÄÖеİ취£¬Äú¿ÉÒÔÔÚÄúµÄÍøÕ¾ÉÏÇáËÉʵÏÖHTTP/2ЭÒéµÄÖ§³Ö¡£

ÒÔÉϾÍÊÇÔõÑùʹÓÃnginxʵÏÖhttp/2ЭÒéÖ§³ÖµÄÏÈÈݺÍʾÀý´úÂ룬ϣÍû¶ÔÄúÓÐËù×ÊÖú£¡

ÒÔÉϾÍÊÇÔõÑùʹÓÃNginxʵÏÖHTTP/2ЭÒéÖ§³ÖµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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