{"id":41782,"date":"2024-10-02T08:26:30","date_gmt":"2024-10-02T00:26:30","guid":{"rendered":"https:\/\/server.hk\/cnblog\/41782\/"},"modified":"2024-10-02T08:26:30","modified_gmt":"2024-10-02T00:26:30","slug":"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_proxy_http%e8%a8%ad%e5%ae%9aapache","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/41782\/","title":{"rendered":"Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_proxy_http\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_http%e8%a8%ad%e5%ae%9aapache-cqJLolfKRV\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_proxy_http\u8a2d\u5b9aApache<\/h1>\n<p>Apache HTTP Server\u662f\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u958b\u6e90\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u64c1\u6709\u5f37\u5927\u7684\u64f4\u5c55\u6027\u548c\u9748\u6d3b\u6027\u3002\u5c0d\u65bc\u65b0\u624b\u4f86\u8aaa\uff0c\u5b78\u6703\u5982\u4f55\u4f7f\u7528Apache\u7684mod_proxy_http\u6a21\u7d44\u4f86\u8a2d\u7f6e\u53cd\u5411\u4ee3\u7406\u662f\u4e00\u9805\u91cd\u8981\u7684\u6280\u80fd\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u914d\u7f6emod_proxy_http\uff0c\u4e26\u63d0\u4f9b\u5be6\u7528\u7684\u7bc4\u4f8b\u548c\u6b65\u9a5f\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afmod_proxy_http%ef%bc%9f-cqJLolfKRV\">\u4ec0\u9ebc\u662fmod_proxy_http\uff1f<\/h2>\n<p>mod_proxy_http\u662fApache\u7684\u4e00\u500b\u6a21\u7d44\uff0c\u5141\u8a31Apache\u4f5c\u70ba\u53cd\u5411\u4ee3\u7406\u4f3a\u670d\u5668\u3002\u9019\u610f\u5473\u8457Apache\u53ef\u4ee5\u63a5\u6536\u5ba2\u6236\u7aef\u7684\u8acb\u6c42\uff0c\u7136\u5f8c\u5c07\u9019\u4e9b\u8acb\u6c42\u8f49\u767c\u5230\u5176\u4ed6\u4f3a\u670d\u5668\u4e0a\uff0c\u4e26\u5c07\u56de\u61c9\u8fd4\u56de\u7d66\u5ba2\u6236\u7aef\u3002\u9019\u7a2e\u8a2d\u7f6e\u5728\u8ca0\u8f09\u5e73\u8861\u3001\u5167\u5bb9\u5206\u767c\u548c\u5b89\u5168\u6027\u65b9\u9762\u90fd\u975e\u5e38\u6709\u7528\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dmod_proxy_http-cqJLolfKRV\">\u5b89\u88ddmod_proxy_http<\/h2>\n<p>\u5728\u5927\u591a\u6578Linux\u767c\u884c\u7248\u4e2d\uff0cmod_proxy_http\u901a\u5e38\u662f\u9810\u8a2d\u5b89\u88dd\u7684\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fUbuntu\u6216Debian\uff0c\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u7528\u5b83\uff1a<\/p>\n<pre><code>sudo a2enmod proxy\nsudo a2enmod proxy_http\nsudo systemctl restart apache2<\/code><\/pre>\n<p>\u5c0d\u65bcCentOS\u6216Red Hat\u7cfb\u7d71\uff0c\u60a8\u53ef\u4ee5\u5728httpd.conf\u6587\u4ef6\u4e2d\u78ba\u8a8dmod_proxy_http\u662f\u5426\u5df2\u7d93\u52a0\u8f09\uff1a<\/p>\n<pre><code>LoadModule proxy_module modules\/mod_proxy.so\nLoadModule proxy_http_module modules\/mod_proxy_http.so<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86-cqJLolfKRV\">\u914d\u7f6e\u53cd\u5411\u4ee3\u7406<\/h2>\n<p>\u4e00\u65e6mod_proxy_http\u88ab\u555f\u7528\uff0c\u60a8\u5c31\u53ef\u4ee5\u958b\u59cb\u914d\u7f6e\u53cd\u5411\u4ee3\u7406\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u57fa\u672c\u7684\u914d\u7f6e\u7bc4\u4f8b\uff0c\u5c07\u6240\u6709\u5c0d\u65bc\/example\u7684\u8acb\u6c42\u8f49\u767c\u5230\u5167\u90e8\u4f3a\u670d\u5668http:\/\/localhost:8080\uff1a<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\n    ServerName www.example.com\n\n    ProxyRequests Off\n    ProxyPass \/example http:\/\/localhost:8080\/\n    ProxyPassReverse \/example http:\/\/localhost:8080\/\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>\u5728\u9019\u500b\u7bc4\u4f8b\u4e2d\uff1a<\/p>\n<ul>\n<li><strong>ProxyRequests Off<\/strong>\uff1a\u9019\u4e00\u884c\u7981\u7528\u4e86\u6b63\u5411\u4ee3\u7406\uff0c\u78ba\u4fddApache\u50c5\u4f5c\u70ba\u53cd\u5411\u4ee3\u7406\u904b\u884c\u3002<\/li>\n<li><strong>ProxyPass<\/strong>\uff1a\u9019\u4e00\u884c\u5c07\u6240\u6709\u5c0d\u65bc\/example\u7684\u8acb\u6c42\u8f49\u767c\u5230http:\/\/localhost:8080\/\u3002<\/li>\n<li><strong>ProxyPassReverse<\/strong>\uff1a\u9019\u4e00\u884c\u78ba\u4fddApache\u80fd\u6b63\u78ba\u8655\u7406\u4f86\u81ea\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u56de\u61c9\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e9%85%8d%e7%bd%ae-cqJLolfKRV\">\u6e2c\u8a66\u914d\u7f6e<\/h2>\n<p>\u5b8c\u6210\u914d\u7f6e\u5f8c\uff0c\u60a8\u9700\u8981\u91cd\u555fApache\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u53ef\u4ee5\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554fhttp:\/\/www.example.com\/example\uff0c\u6aa2\u67e5\u662f\u5426\u80fd\u6b63\u78ba\u986f\u793a\u4f86\u81ea\u5167\u90e8\u4f3a\u670d\u5668\u7684\u5167\u5bb9\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u56de\u61c9\u3002<\/p>\n<h2 id=\"%e6%95%85%e9%9a%9c%e6%8e%92%e9%99%a4-cqJLolfKRV\">\u6545\u969c\u6392\u9664<\/h2>\n<p>\u5982\u679c\u60a8\u9047\u5230\u554f\u984c\uff0c\u53ef\u4ee5\u6aa2\u67e5Apache\u7684\u932f\u8aa4\u65e5\u8a8c\uff0c\u901a\u5e38\u4f4d\u65bc\/var\/log\/apache2\/error.log\uff08Ubuntu\/Debian\uff09\u6216\/var\/log\/httpd\/error_log\uff08CentOS\/Red Hat\uff09\u3002\u5e38\u898b\u7684\u554f\u984c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u672a\u555f\u7528mod_proxy_http\u6a21\u7d44\u3002<\/li>\n<li>ProxyPass\u6216ProxyPassReverse\u914d\u7f6e\u932f\u8aa4\u3002<\/li>\n<li>\u5f8c\u7aef\u4f3a\u670d\u5668\u672a\u904b\u884c\u6216\u7121\u6cd5\u8a2a\u554f\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-cqJLolfKRV\">\u7e3d\u7d50<\/h2>\n<p>\u4f7f\u7528mod_proxy_http\u8a2d\u5b9aApache\u4f5c\u70ba\u53cd\u5411\u4ee3\u7406\u662f\u4e00\u500b\u5f37\u5927\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5e6b\u52a9\u60a8\u7ba1\u7406\u6d41\u91cf\u548c\u63d0\u9ad8\u61c9\u7528\u7a0b\u5e8f\u7684\u53ef\u7528\u6027\u3002\u901a\u904e\u672c\u6587\u7684\u6307\u5c0e\uff0c\u60a8\u61c9\u8a72\u80fd\u5920\u6210\u529f\u914d\u7f6eApache\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u591a\u7684\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u548c\u5176\u4ed6\u76f8\u95dc\u670d\u52d9\uff0c\u5e6b\u52a9\u60a8\u5728\u7db2\u7d61\u4e0a\u53d6\u5f97\u6210\u529f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528mod_proxy_http\u8a2d\u5b9aApache\uff0c\u8f15\u9b06\u5be6\u73fe\u53cd\u5411\u4ee3\u7406\u529f\u80fd\uff0c\u63d0\u5347\u7db2\u7ad9\u6027\u80fd\u8207\u9748\u6d3b\u6027\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-41782","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41782","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=41782"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41782\/revisions"}],"predecessor-version":[{"id":41783,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41782\/revisions\/41783"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=41782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=41782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=41782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}