{"id":41640,"date":"2024-10-02T02:27:57","date_gmt":"2024-10-01T18:27:57","guid":{"rendered":"https:\/\/server.hk\/cnblog\/41640\/"},"modified":"2024-10-02T02:27:58","modified_gmt":"2024-10-01T18:27:58","slug":"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_proxy_http2%e8%a8%ad%e5%ae%9aapache","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/41640\/","title":{"rendered":"Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_proxy_http2\u8a2d\u5b9aApache"},"content":{"rendered":"<h1 id=\"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_proxy_http2%e8%a8%ad%e5%ae%9aapache-tuPafScNwe\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_proxy_http2\u8a2d\u5b9aApache<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cApache\u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u7db2\u7ad9\u548c\u61c9\u7528\u7a0b\u5f0f\u3002\u96a8\u8457HTTP\/2\u7684\u8208\u8d77\uff0c\u8a31\u591a\u7db2\u7ad9\u958b\u59cb\u5c0b\u6c42\u66f4\u9ad8\u6548\u7684\u6578\u64da\u50b3\u8f38\u65b9\u5f0f\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728Apache\u4e2d\u4f7f\u7528mod_proxy_http2\u6a21\u7d44\u4f86\u8a2d\u5b9aHTTP\/2\u4ee3\u7406\uff0c\u5e6b\u52a9\u65b0\u624b\u7528\u6236\u66f4\u597d\u5730\u7406\u89e3\u548c\u5be6\u73fe\u9019\u4e00\u529f\u80fd\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afmod_proxy_http2%ef%bc%9f-tuPafScNwe\">\u4ec0\u9ebc\u662fmod_proxy_http2\uff1f<\/h2>\n<p>mod_proxy_http2\u662fApache\u7684\u4e00\u500b\u6a21\u7d44\uff0c\u5141\u8a31\u7528\u6236\u901a\u904eHTTP\/2\u5354\u8b70\u9032\u884c\u4ee3\u7406\u3002HTTP\/2\u76f8\u8f03\u65bcHTTP\/1.1\uff0c\u63d0\u4f9b\u4e86\u66f4\u5feb\u7684\u52a0\u8f09\u901f\u5ea6\u548c\u66f4\u9ad8\u7684\u6548\u7387\uff0c\u7279\u5225\u662f\u5728\u591a\u500b\u8acb\u6c42\u7684\u60c5\u6cc1\u4e0b\u3002\u9019\u4f7f\u5f97\u7db2\u7ad9\u80fd\u5920\u66f4\u5feb\u901f\u5730\u97ff\u61c9\u7528\u6236\u8acb\u6c42\uff0c\u63d0\u5347\u7528\u6236\u9ad4\u9a57\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dapache%e5%8f%8amod_proxy_http2-tuPafScNwe\">\u5b89\u88ddApache\u53camod_proxy_http2<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u78ba\u4fdd\u4f60\u7684\u4f3a\u670d\u5668\u4e0a\u5df2\u7d93\u5b89\u88dd\u4e86Apache\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88ddApache\uff1a<\/p>\n<pre><code>sudo apt-get update\nsudo apt-get install apache2<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u555f\u7528mod_proxy\u548cmod_proxy_http2\u6a21\u7d44\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u7528\u9019\u4e9b\u6a21\u7d44\uff1a<\/p>\n<pre><code>sudo a2enmod proxy\nsudo a2enmod proxy_http2<\/code><\/pre>\n<p>\u5b8c\u6210\u5f8c\uff0c\u91cd\u555fApache\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%aeapache%e4%bb%a5%e4%bd%bf%e7%94%a8mod_proxy_http2-tuPafScNwe\">\u914d\u7f6eApache\u4ee5\u4f7f\u7528mod_proxy_http2<\/h2>\n<p>\u5728Apache\u4e2d\u914d\u7f6emod_proxy_http2\u76f8\u5c0d\u7c21\u55ae\u3002\u9996\u5148\uff0c\u6253\u958bApache\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u901a\u5e38\u4f4d\u65bc\/etc\/apache2\/sites-available\/000-default.conf\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u958b\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/apache2\/sites-available\/000-default.conf<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\n    ServerName yourdomain.com\n\n    ProxyPass \/ http:\/\/backend-server.com\/\n    ProxyPassReverse \/ http:\/\/backend-server.com\/\n\n    Protocols h2 http\/1.1\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>\u5728\u4e0a\u8ff0\u914d\u7f6e\u4e2d\uff0c\u5c07\u201cyourdomain.com\u201d\u66ff\u63db\u70ba\u4f60\u7684\u57df\u540d\uff0c\u4e26\u5c07\u201cbackend-server.com\u201d\u66ff\u63db\u70ba\u4f60\u7684\u5f8c\u7aef\u4f3a\u670d\u5668\u5730\u5740\u3002\u9019\u6a23\u914d\u7f6e\u5f8c\uff0cApache\u5c07\u6703\u5c07\u6240\u6709\u8acb\u6c42\u8f49\u767c\u5230\u6307\u5b9a\u7684\u5f8c\u7aef\u4f3a\u670d\u5668\uff0c\u4e26\u4f7f\u7528HTTP\/2\u5354\u8b70\u9032\u884c\u901a\u4fe1\u3002<\/p>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e9%85%8d%e7%bd%ae-tuPafScNwe\">\u6e2c\u8a66\u914d\u7f6e<\/h2>\n<p>\u5b8c\u6210\u914d\u7f6e\u5f8c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5Apache\u7684\u914d\u7f6e\u662f\u5426\u6b63\u78ba\uff1a<\/p>\n<pre><code>sudo apachectl configtest<\/code><\/pre>\n<p>\u5982\u679c\u6c92\u6709\u932f\u8aa4\uff0c\u5247\u53ef\u4ee5\u91cd\u555fApache\u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u53ef\u4ee5\u4f7f\u7528\u700f\u89bd\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982curl\uff09\u4f86\u6e2c\u8a66HTTP\/2\u662f\u5426\u6b63\u5e38\u5de5\u4f5c\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5HTTP\u7248\u672c\uff1a<\/p>\n<pre><code>curl -I -s --http2 https:\/\/yourdomain.com<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u4f60\u61c9\u8a72\u80fd\u770b\u5230HTTP\/2\u7684\u97ff\u61c9\u6a19\u982d\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-tuPafScNwe\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u4f60\u5df2\u7d93\u6210\u529f\u5728Apache\u4e2d\u914d\u7f6e\u4e86mod_proxy_http2\uff0c\u9019\u5c07\u6709\u52a9\u65bc\u63d0\u5347\u7db2\u7ad9\u7684\u6027\u80fd\u548c\u7528\u6236\u9ad4\u9a57\u3002\u96a8\u8457\u7db2\u7d61\u6280\u8853\u7684\u767c\u5c55\uff0cHTTP\/2\u5c07\u6210\u70ba\u672a\u4f86\u7684\u4e3b\u6d41\u5354\u8b70\uff0c\u638c\u63e1\u9019\u4e00\u6280\u8853\u5c07\u5c0d\u7db2\u7ad9\u7ba1\u7406\u8005\u5927\u6709\u88e8\u76ca\u3002\u5982\u679c\u4f60\u6b63\u5728\u5c0b\u627e\u7a69\u5b9a\u7684\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u4f86\u652f\u6301\u4f60\u7684\u7db2\u7ad9\u904b\u884c\uff0c\u4eab\u53d7\u66f4\u9ad8\u6548\u7684\u6578\u64da\u50b3\u8f38\u548c\u66f4\u4f73\u7684\u7528\u6236\u9ad4\u9a57\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528mod_proxy_http2\u8a2d\u5b9aApache\uff0c\u63d0\u5347\u7db2\u7ad9\u6027\u80fd\u8207\u6548\u7387\uff0c\u9069\u5408Apache\u65b0\u624b\u7684\u8a73\u7d30\u6559\u7a0b\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-41640","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=41640"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41640\/revisions"}],"predecessor-version":[{"id":41641,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41640\/revisions\/41641"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=41640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=41640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=41640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}