{"id":9193,"date":"2024-08-06T14:02:52","date_gmt":"2024-08-06T06:02:52","guid":{"rendered":"https:\/\/www.choubb.com\/?p=9193"},"modified":"2024-08-09T09:33:14","modified_gmt":"2024-08-09T01:33:14","slug":"%e7%ab%99%e7%82%b9%e5%8d%87%e7%ba%a7http2","status":"publish","type":"post","link":"https:\/\/www.choubb.com\/?p=9193","title":{"rendered":"\u7ad9\u70b9\u5347\u7ea7http2"},"content":{"rendered":"\n<p>\u5076\u5c14\u5f97\u77e5http2\u5df2\u7ecf\u6d41\u884c\u5f88\u4e45\u4e86\uff0c\u80af\u5b9a\u6709\u4e0d\u5c11\u4f18\u52bf\uff0c\u5e94\u7528\u73af\u5883\u5e94\u5f53\u4e5f\u7a33\u5b9a\u4e86\uff0c\u67e5\u4e86\u67e5\u5347\u7ea7\u65b9\u6cd5\u7adf\u7136\u53d1\u73b0\u610f\u5916\u7684\u7b80\u5355\uff0c\u6628\u65e5\u9042\u987a\u624b\u5347\u4e4b\u3002\u9694\u591c\u68c0\u89c6\u672c\u7ad9\u8fd0\u4f5c\uff0c\u4e00\u5207\u6b63\u5e38\uff0c\u4e43\u4f5c\u6b64\u8bb0\u4ee5\u5907\u540e\u67e5\u3002<\/p>\n\n\n\n<p>\u8fd8\u662f\u8001\u89c4\u77e9\u5148\u53bb\u6570\u6d77\u7f51\u67e5\u5347\u7ea7\u653b\u7565\u3002\u7f51\u4e0a\u904d\u5730\u653b\u7565\uff0c\u5927\u591a\u4e0d\u751a\u5b8c\u5907\u5468\u8be6\uff0c\u6211\u7684\u7ecf\u9a8c\u662f\u6570\u6d77\u7f51\u7684\u77e5\u8bc6\u5e93\u4e2d\u7684\u5404\u79cd\u653b\u7565\u975e\u5e38\u8be6\u5b9e\u53ef\u9760\uff0c\u5927\u591a\u90fd\u80fd\u5177\u4f53\u5230OS\u7684\u5927\u7248\u672c\uff0c\u66f4\u4e0d\u5fc5\u8bf4\u7bc7\u7bc7\u5fc5\u5907\u7684\u5b89\u88c5\u51c6\u5907\u548c\u5b89\u88c5\u540e\u7684\u68c0\u9a8c\u65b9\u6cd5\u4e86\uff0c\u8fd9\u7bc7Ubuntu22.04 Nginx\u5347\u7ea7http2\u7684\u653b\u7565\u4e5f\u4e0d\u4f8b\u5916\uff0c\u94fe\u63a5\u62ff\u53bb\uff1a<a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-nginx-with-http-2-support-on-ubuntu-22-04\" data-type=\"link\" data-id=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-nginx-with-http-2-support-on-ubuntu-22-04\">https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-nginx-with-http-2-support-on-ubuntu-22-04<\/a><\/p>\n\n\n\n<p>\u7b2c\u4e00\u6b65\uff1a\u67e5\u5b89\u88c5\u51c6\u5907\uff0c\u4ee5\u4e0b\u7eff\u8272\u4e3aOK,\u68d5\u8272\u4e3a\u975e\u76f8\u5173\uff0c\u84dd\u8272\u4e43\u672a\u77e5\u3002\u5728\u6709\u4e00\u9879\u672a\u77e5\u7684\u60c5\u51b5\u4e0b\u6211\u5c31\u5f00\u59cb\u4e86\u5347\u7ea7\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color has-link-color wp-elements-4b78554445c5e395ebf224a102ac82fa\">An Ubuntu 22.04 server set up by following the Ubuntu 22.04 initial server setup guide, including a sudo non-root user and a firewall.<br \/>Nginx installed on your server, which you can do by following How To Install Nginx on Ubuntu 22.04.<br \/>A domain name configured to point to your server. You can purchase one on Namecheap or get one for free on Freenom. You can learn how to point domains to DigitalOcean Droplets by following the documentation on How To Manage Your Domain With DigitalOcean.<br \/>A TLS\/SSL certificate configured for your server. You have two options:<br \/>You can get a free certificate from Let\u2019s Encrypt by following How to Secure Nginx with Let\u2019s Encrypt on Ubuntu 22.04.<\/p>\n\n\n\n<p class=\"has-luminous-vivid-orange-color has-text-color has-link-color wp-elements-db2cf27a8e5ddf729e056d3d53764a71\"><br \/>You can also generate and configure a self-signed certificate by following How to Create a Self-signed SSL Certificate for Nginx in Ubuntu 22.04.<\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color has-link-color wp-elements-ae3bbceeb9287aa8d9d57ad9f5ed3a9c\"><br \/>Nginx configured to redirect traffic from port 80 to port 443, which should be covered by the previous prerequisites.<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-8cfee1d1803bd8a484decefc3f7862b7\"><br \/>Nginx configured to use a 2048-bit or higher Ephemeral Diffie-Hellman (DHE) key, which should also be covered by the previous prerequisites.<\/p>\n\n\n\n<p>\u7b2c\u4e8c\u6b65\uff1a \u5347\u7ea7<\/p>\n\n\n\n<p>sudo vim \/etc\/nginx\/sites-enabled\/choubb.com\uff0c\u5728\u4e0b\u5217\u5b57\u6bb5\u4e2d\u52a0http2\u5982\u4e0b\uff0c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>listen 443 ssl http2; # managed by Certbot<br \/>listen &#91;::]:443 ssl http2; #ipv6 support<\/code><\/pre>\n\n\n\n<p>\u7136\u540esudo nginx -t\u68c0\u67e5\u8bed\u53e5\uff0c\u7ee7\u7eedsudo vim \/etc\/nginx\/sites-enabled\/choubb.com\uff0c\u4ee5#\u505c\u7528options-ssl-nginx.conf\u7684\u8bed\u53e5\uff0c\u589e\u52a0\u4e0b\u4e24\u6761\u8bed\u53e5\uff0c\u4ee5\u8fbe\u5230http2\u7684\u52a0\u5bc6\u8981\u6c42\u3002http2\u672c\u65e0\u52a0\u5bc6\u8981\u6c42\uff0c\u4f46\u662f\u72d7\u54e5\u548c\u706b\u72d0\u5f3a\u5236http2\u52a0\u5bc6\u6807\u51c6\uff0c\u6210\u4e86\u4e8b\u5b9e\u6807\u51c6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># include \/etc\/letsencrypt\/options-ssl-nginx.conf; # managed by Certbot\nssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;\nadd_header Strict-Transport-Security \"max-age=15768000\" always;<\/code><\/pre>\n\n\n\n<p>\u5b58\u76d8\u540e\uff0csudo nginx -t\u68c0\u67e5\u8bed\u53e5\uff0csudo systemctl reload nginx.service\u91cd\u542fNginx,\u5927\u529f\u544a\u6210\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e09\u6b65\uff1a\u68c0\u67e5<\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e00\uff1acurl -I -L &#8211;http2 https:\/\/www.choubb.com<br \/>\u65b9\u6cd5\u4e8c\uff1a\u4ee5\u6d4f\u89c8\u5668\u6253\u5f00www.choubb.com\uff0cF12\u70b9\u7f51\u7edc\uff0c\u8868\u5185\u53f3\u952e\u9009\u4e2d\u534f\u8bae\uff0c\u5217\u8868\u91cc\u5c31\u53ef\u770b\u5230http2\u6216\u8005H2\u7684\u5b57\u6837\uff0c\u8bc1\u660e\u5347\u7ea7\u6210\u529f\u4e86\u3002\u4e0b\u56fe\u5c31\u662f\u5728\u7f16\u8f91\u5668\u91cc\u7f16\u8f91\u672c\u9875\u662f\u7684\u622a\u56fe\uff0c\u53ef\u89c1http1.1\u8fd8\u662f\u6709\u7684\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/pic.imgdb.cn\/item\/66b1bbdfd9c307b7e9580e9d.png\" alt=\"\" style=\"width:687px;height:auto\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u5076\u5c14\u5f97\u77e5http2\u5df2\u7ecf\u6d41\u884c\u5f88\u4e45\u4e86\uff0c\u80af\u5b9a\u6709\u4e0d\u5c11\u4f18\u52bf\uff0c\u5e94\u7528\u73af\u5883\u5e94\u5f53\u4e5f\u7a33\u5b9a\u4e86\uff0c\u67e5\u4e86\u67e5\u5347\u7ea7\u65b9\u6cd5\u7adf\u7136\u53d1\u73b0\u610f\u5916\u7684\u7b80\u5355\uff0c\u6628\u65e5\u9042\u987a\u624b\u5347\u4e4b\u3002\u9694\u591c\u68c0\u89c6\u672c\u7ad9\u8fd0\u4f5c\uff0c\u4e00\u5207\u6b63\u5e38\uff0c\u4e43\u4f5c\u6b64\u8bb0\u4ee5\u5907\u540e\u67e5\u3002 \u8fd8\u662f\u8001\u89c4\u77e9\u5148\u53bb\u6570\u6d77\u7f51\u67e5\u5347\u7ea7\u653b\u7565\u3002\u7f51\u4e0a\u904d\u5730\u653b\u7565\uff0c\u5927\u591a\u4e0d\u751a\u5b8c\u5907\u5468\u8be6\uff0c\u6211\u7684\u7ecf\u9a8c\u662f\u6570\u6d77\u7f51\u7684\u77e5\u8bc6\u5e93\u4e2d\u7684\u5404\u79cd\u653b\u7565\u975e\u5e38\u8be6\u5b9e\u53ef\u9760\uff0c\u5927\u591a\u90fd\u80fd\u5177\u4f53\u5230OS\u7684\u5927\u7248\u672c\uff0c\u66f4\u4e0d\u5fc5\u8bf4\u7bc7\u7bc7\u5fc5\u5907\u7684\u5b89\u88c5\u51c6\u5907\u548c\u5b89\u88c5\u540e\u7684\u68c0\u9a8c\u65b9\u6cd5\u4e86\uff0c\u8fd9\u7bc7Ubuntu22.04 Nginx\u5347\u7ea7http2\u7684\u653b\u7565\u4e5f\u4e0d\u4f8b\u5916\uff0c\u94fe\u63a5\u62ff\u53bb\uff1ahttps:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-nginx-with-http-2-support-on-ubuntu-22-04 \u7b2c\u4e00\u6b65\uff1a\u67e5\u5b89\u88c5\u51c6\u5907\uff0c\u4ee5\u4e0b\u7eff\u8272\u4e3aOK,\u68d5\u8272\u4e3a\u975e\u76f8\u5173\uff0c\u84dd\u8272\u4e43\u672a\u77e5\u3002\u5728\u6709\u4e00\u9879\u672a\u77e5\u7684\u60c5\u51b5\u4e0b\u6211\u5c31\u5f00\u59cb\u4e86\u5347\u7ea7\u8fc7\u7a0b\u3002 An Ubuntu 22.04 server set up by following the Ubuntu 22.04 initial server setup guide, including a sudo non-root user and a firewall.Nginx installed on your server, which<a class=\"moretag\" href=\"https:\/\/www.choubb.com\/?p=9193\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2287,201],"tags":[5055,5054,5056],"class_list":["post-9193","post","type-post","status-publish","format-standard","hentry","category-2287","category-201","tag-h2","tag-http2","tag-5056"],"_links":{"self":[{"href":"https:\/\/www.choubb.com\/index.php?rest_route=\/wp\/v2\/posts\/9193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.choubb.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.choubb.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.choubb.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.choubb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9193"}],"version-history":[{"count":3,"href":"https:\/\/www.choubb.com\/index.php?rest_route=\/wp\/v2\/posts\/9193\/revisions"}],"predecessor-version":[{"id":9199,"href":"https:\/\/www.choubb.com\/index.php?rest_route=\/wp\/v2\/posts\/9193\/revisions\/9199"}],"wp:attachment":[{"href":"https:\/\/www.choubb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.choubb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.choubb.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}