{"id":36177,"date":"2024-10-01T00:57:05","date_gmt":"2024-09-30T16:57:05","guid":{"rendered":"https:\/\/server.hk\/cnblog\/36177\/"},"modified":"2024-10-01T00:57:06","modified_gmt":"2024-09-30T16:57:06","slug":"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_lbmethod_byrequests%e9%80%b2%e8%a1%8c%e8%ab%8b%e6%b1%82%e8%a8%88%e6%95%b8%e8%b2%a0%e8%bc%89%e5%9d%87%e8%a1%a1","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/36177\/","title":{"rendered":"Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_lbmethod_byrequests\u9032\u884c\u8acb\u6c42\u8a08\u6578\u8ca0\u8f09\u5747\u8861"},"content":{"rendered":"<h1 id=\"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_lbmethod_byrequests%e9%80%b2%e8%a1%8c%e8%ab%8b%e6%b1%82%e8%a8%88%e6%95%b8%e8%b2%a0%e8%bc%89%e5%9d%87%e8%a1%a1-PjBuiNxYAQ\">Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_lbmethod_byrequests\u9032\u884c\u8acb\u6c42\u8a08\u6578\u8ca0\u8f09\u5747\u8861<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0c\u7db2\u7ad9\u7684\u53ef\u7528\u6027\u548c\u6027\u80fd\u81f3\u95dc\u91cd\u8981\u3002Apache\u4f5c\u70ba\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u8ca0\u8f09\u5747\u8861\u65b9\u6cd5\u4f86\u78ba\u4fdd\u6d41\u91cf\u7684\u6709\u6548\u7ba1\u7406\u3002\u5176\u4e2d\uff0c<code>mod_lbmethod_byrequests<\/code>\u662f\u4e00\u7a2e\u57fa\u65bc\u8acb\u6c42\u8a08\u6578\u7684\u8ca0\u8f09\u5747\u8861\u6a21\u7d44\uff0c\u80fd\u5920\u6709\u6548\u5730\u5206\u914d\u9032\u5165\u7684\u8acb\u6c42\uff0c\u5f9e\u800c\u63d0\u9ad8\u4f3a\u670d\u5668\u7684\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afmod_lbmethod_byrequests%ef%bc%9f-PjBuiNxYAQ\">\u4ec0\u9ebc\u662fmod_lbmethod_byrequests\uff1f<\/h2>\n<p><code>mod_lbmethod_byrequests<\/code>\u662fApache\u7684\u8ca0\u8f09\u5747\u8861\u6a21\u7d44\u4e4b\u4e00\uff0c\u4e3b\u8981\u7528\u65bc\u6839\u64da\u8acb\u6c42\u7684\u6578\u91cf\u4f86\u5206\u914d\u6d41\u91cf\u3002\u9019\u7a2e\u65b9\u6cd5\u7279\u5225\u9069\u5408\u65bc\u8655\u7406\u77ed\u671f\u8acb\u6c42\uff0c\u56e0\u70ba\u5b83\u80fd\u5920\u6839\u64da\u6bcf\u500b\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u8acb\u6c42\u6578\u91cf\u4f86\u52d5\u614b\u8abf\u6574\u6d41\u91cf\u5206\u914d\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%81%b8%e6%93%87%e8%ab%8b%e6%b1%82%e8%a8%88%e6%95%b8%e8%b2%a0%e8%bc%89%e5%9d%87%e8%a1%a1%ef%bc%9f-PjBuiNxYAQ\">\u70ba\u4ec0\u9ebc\u9078\u64c7\u8acb\u6c42\u8a08\u6578\u8ca0\u8f09\u5747\u8861\uff1f<\/h2>\n<ul>\n<li><strong>\u7c21\u55ae\u6613\u7528\uff1a<\/strong>\u8acb\u6c42\u8a08\u6578\u8ca0\u8f09\u5747\u8861\u7684\u914d\u7f6e\u76f8\u5c0d\u7c21\u55ae\uff0c\u9069\u5408\u5404\u7a2e\u898f\u6a21\u7684\u7db2\u7ad9\u3002<\/li>\n<li><strong>\u9ad8\u6548\u6027\uff1a<\/strong>\u901a\u904e\u5747\u8861\u8acb\u6c42\u6578\u91cf\uff0c\u53ef\u4ee5\u6709\u6548\u907f\u514d\u67d0\u4e00\u4f3a\u670d\u5668\u904e\u8f09\uff0c\u5f9e\u800c\u63d0\u9ad8\u6574\u9ad4\u6027\u80fd\u3002<\/li>\n<li><strong>\u9748\u6d3b\u6027\uff1a<\/strong>\u53ef\u4ee5\u6839\u64da\u5be6\u969b\u9700\u6c42\u8abf\u6574\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u6578\u91cf\u548c\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aemod_lbmethod_byrequests-PjBuiNxYAQ\">\u5982\u4f55\u914d\u7f6emod_lbmethod_byrequests<\/h2>\n<p>\u8981\u4f7f\u7528<code>mod_lbmethod_byrequests<\/code>\uff0c\u9996\u5148\u9700\u8981\u78ba\u4fddApache\u5df2\u7d93\u5b89\u88dd\u4e86\u8a72\u6a21\u7d44\u3002\u63a5\u4e0b\u4f86\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\u914d\u7f6e\uff1a<\/p>\n<pre><code>\n# \u555f\u7528\u8ca0\u8f09\u5747\u8861\u6a21\u7d44\nLoadModule lbmethod_byrequests_module modules\/mod_lbmethod_byrequests.so\n\n# \u8a2d\u5b9a\u8ca0\u8f09\u5747\u8861\u96c6\u7fa4\n&lt;Proxy balancer:\/\/mycluster&gt;\n    BalancerMember http:\/\/192.168.1.1:80\n    BalancerMember http:\/\/192.168.1.2:80\n    BalancerMember http:\/\/192.168.1.3:80\n    ProxySet lbmethod=byrequests\n&lt;\/Proxy&gt;\n\n# \u4f7f\u7528ProxyPass\u5c07\u8acb\u6c42\u5c0e\u5411\u8ca0\u8f09\u5747\u8861\u96c6\u7fa4\nProxyPass \/ balancer:\/\/mycluster\/\nProxyPassReverse \/ balancer:\/\/mycluster\/\n<\/code><\/pre>\n<p>\u5728\u4e0a\u8ff0\u914d\u7f6e\u4e2d\uff0c\u6211\u5011\u9996\u5148\u555f\u7528\u4e86<code>mod_lbmethod_byrequests<\/code>\u6a21\u7d44\uff0c\u7136\u5f8c\u5b9a\u7fa9\u4e86\u4e00\u500b\u540d\u70ba<code>mycluster<\/code>\u7684\u8ca0\u8f09\u5747\u8861\u96c6\u7fa4\uff0c\u4e26\u6dfb\u52a0\u4e86\u4e09\u500b\u5f8c\u7aef\u4f3a\u670d\u5668\u3002\u6700\u5f8c\uff0c\u901a\u904e<code>ProxyPass<\/code>\u6307\u4ee4\u5c07\u6240\u6709\u8acb\u6c42\u5c0e\u5411\u8a72\u96c6\u7fa4\u3002<\/p>\n<h2 id=\"%e5%ae%89%e5%85%a8%e6%80%a7%e8%80%83%e9%87%8f-PjBuiNxYAQ\">\u5b89\u5168\u6027\u8003\u91cf<\/h2>\n<p>\u5728\u4f7f\u7528<code>mod_lbmethod_byrequests<\/code>\u9032\u884c\u8ca0\u8f09\u5747\u8861\u6642\uff0c\u5b89\u5168\u6027\u662f\u4e0d\u53ef\u5ffd\u8996\u7684\u56e0\u7d20\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5efa\u8b70\uff1a<\/p>\n<ul>\n<li><strong>\u4f7f\u7528HTTPS\uff1a<\/strong>\u78ba\u4fdd\u6240\u6709\u7684\u6d41\u91cf\u90fd\u901a\u904eHTTPS\u9032\u884c\u52a0\u5bc6\uff0c\u4fdd\u8b77\u7528\u6236\u6578\u64da\u7684\u5b89\u5168\u3002<\/li>\n<li><strong>\u9650\u5236\u8a2a\u554f\uff1a<\/strong>\u901a\u904e\u9632\u706b\u7246\u6216\u5176\u4ed6\u5b89\u5168\u63aa\u65bd\u9650\u5236\u5c0d\u5f8c\u7aef\u4f3a\u670d\u5668\u7684\u76f4\u63a5\u8a2a\u554f\u3002<\/li>\n<li><strong>\u76e3\u63a7\u6d41\u91cf\uff1a<\/strong>\u5b9a\u671f\u6aa2\u67e5\u6d41\u91cf\u65e5\u8a8c\uff0c\u53ca\u6642\u767c\u73fe\u7570\u5e38\u8acb\u6c42\u6216\u653b\u64ca\u884c\u70ba\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-PjBuiNxYAQ\">\u7d50\u8ad6<\/h2>\n<p>\u4f7f\u7528<code>mod_lbmethod_byrequests<\/code>\u9032\u884c\u8acb\u6c42\u8a08\u6578\u8ca0\u8f09\u5747\u8861\u662f\u4e00\u7a2e\u6709\u6548\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u63d0\u9ad8Apache\u4f3a\u670d\u5668\u7684\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002\u901a\u904e\u5408\u7406\u7684\u914d\u7f6e\u548c\u5b89\u5168\u63aa\u65bd\uff0c\u7db2\u7ad9\u7ba1\u7406\u54e1\u53ef\u4ee5\u78ba\u4fdd\u5176\u7db2\u7ad9\u5728\u9ad8\u6d41\u91cf\u60c5\u6cc1\u4e0b\u4f9d\u7136\u80fd\u5920\u7a69\u5b9a\u904b\u884c\u3002\u5c0d\u65bc\u5c0b\u6c42\u9ad8\u6548\u80fd\u548c\u5b89\u5168\u6027\u7684\u7528\u6236\uff0c\u9078\u64c7\u5408\u9069\u7684<code>VPS<\/code>\u89e3\u6c7a\u65b9\u6848\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u4e86\u89e3\u66f4\u591a\u95dc\u65bc<code>\u9999\u6e2fVPS<\/code>\u548c<code>\u4f3a\u670d\u5668<\/code>\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f<a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3Apache\u5b89\u5168\u7b56\u7565\uff0c\u4f7f\u7528mod_lbmethod_byrequests\u9032\u884c\u8acb\u6c42\u8a08\u6578\u8ca0\u8f09\u5747\u8861\uff0c\u63d0\u5347\u7db2\u7ad9\u6027\u80fd\u8207\u7a69\u5b9a\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-36177","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/36177","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=36177"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/36177\/revisions"}],"predecessor-version":[{"id":36178,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/36177\/revisions\/36178"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=36177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=36177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=36177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}