{"id":46533,"date":"2023-04-22T13:28:39","date_gmt":"2023-04-22T05:28:39","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=46533"},"modified":"2023-04-22T13:28:39","modified_gmt":"2023-04-22T05:28:39","slug":"redhat7-haproxy-weblb","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/redhat7-haproxy-weblb.html","title":{"rendered":"RHEL 7\u914d\u7f6eHAProxy\u5b9e\u73b0Web\u8d1f\u8f7d\u5747\u8861"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6587\u5c06\u7b80\u5355\u4ecb\u7ecd\u4f7f\u7528HAProxy\u5b9e\u73b0web\u8d1f\u8f7d\u5747\u8861\uff0c\u4e3b\u8981\u5185\u5bb9\u5305\u62ec\u57fa\u4e8e\u6743\u91cd\u7684\u8f6e\u8be2\u3001\u4e3aHAProxy\u914d\u7f6ehttps\u3001\u914d\u7f6ehttp\u91cd\u5b9a\u5411\u4e3ahttps\u3001\u914d\u7f6eHAProxy\u4f7f\u7528\u72ec\u7acb\u65e5\u5fd7\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e00\u3001\u6d4b\u8bd5\u73af\u5883<\/strong><\/div>\n
HAProxy\uff1a<\/strong><\/span><\/div>\n

\u4e3b\u673a\u540d\uff1aRH7-HAProxy
\nIP\u5730\u5740\uff1a192.168.10.20
\n\u64cd\u4f5c\u7cfb\u7edf\uff1aRed Hat Enterprise Linux Server release 7.2 (Maipo)\u6700\u5c0f\u5316\u5b89\u88c5
\n\u9632\u706b\u5899\u4e0eSELinux\uff1a\u5173\u95ed
\n\u5b89\u88c5\u7684\u670d\u52a1\uff1aHAProxy-1.5.14<\/p>\n

WEB01:<\/strong><\/span><\/div>\n

\u4e3b\u673a\u540d\uff1aRH7-Web-01
\nIP\u5730\u5740\uff1a192.168.10.21
\n\u64cd\u4f5c\u7cfb\u7edf\uff1aRed Hat Enterprise Linux Server release 7.2 (Maipo)\u6700\u5c0f\u5316\u5b89\u88c5
\n\u9632\u706b\u5899\u4e0eSELinux\uff1a\u5173\u95ed
\n\u5b89\u88c5\u7684\u670d\u52a1\uff1aApache-httpd 2.4<\/p>\n

WEB02:<\/strong><\/span><\/div>\n

\u4e3b\u673a\u540d\uff1aRH7-Web-02
\nIP\u5730\u5740\uff1a192.168.10.22
\n\u64cd\u4f5c\u7cfb\u7edf\uff1aRed Hat Enterprise Linux Server release 7.2 (Maipo)\u6700\u5c0f\u5316\u5b89\u88c5
\n\u9632\u706b\u5899\u4e0eSELinux\uff1a\u5173\u95ed
\n\u5b89\u88c5\u7684\u670d\u52a1\uff1aApache-httpd 2.4<\/p>\n

\u4e8c\u3001WEB\u9875\u9762\u8bbf\u95ee\u6d4b\u8bd5<\/strong><\/div>\n

1\u3001\u4f7f\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee\u4e24\u53f0web\u7684IP\u5730\u5740\uff0c\u80fd\u6210\u529f\u8bbf\u95ee\u5230\u4e0d\u540c\u7684\u9875\u9762\uff0c\u65b9\u4fbf\u6211\u4eec\u540e\u9762\u76f4\u89c2\u5730\u89c2\u5bdf\u8d1f\u8f7d\u5747\u8861\u7684\u6548\u679c\u3002\u7531\u4e8eApache\u7684\u5b89\u88c5\u914d\u7f6e\u4e0d\u662f\u672c\u6587\u91cd\u70b9\uff0c\u5177\u4f53\u53ef\u53c2\u8003\u672c\u4eba\u4e4b\u524d\u7684\u535a\u6587\u300aRedHat 7\u5b89\u88c5\u914d\u7f6eApache 2.4\u300b
\n\"\"<\/p>\n

2\u3001\u5728RH7-HAProxy\u4e0a\u4e5f\u8bbf\u95ee\u4e00\u4e0b\u4e24\u53f0Web\uff0c\u786e\u8ba4\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee
\n\"\"<\/p>\n

\u4e09\u3001\u5b89\u88c5\u914d\u7f6eHAProxy<\/strong><\/div>\n
[root@RH7-HAProxy~]yum -y install haproxy\r\n[root@RH7-HAProxy~]systemctl start haproxy\r\n[root@RH7-HAProxy~]systemctl enable haproxy\r\n[root@RH7-HAProxy~]mv \/etc\/haproxy\/haproxy.cfg \/etc\/haproxy\/haproxy.cfg.bak\r\n[root@RH7-HAProxy~]vi \/etc\/haproxy\/haproxy.cfg\r\n<\/pre>\n

\u589e\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff0c\u7136\u540e\u91cd\u542fhaproxy\u670d\u52a1
\n\"\"
\n\u4f7f\u7528\u6d4f\u89c8\u5668\u8bbf\u95eeHAProxy\u7684IP\u5730\u5740\uff0c\u591a\u6b21\u5237\u65b0\uff0c\u6210\u529f\u5b9e\u73b0\u8f6e\u8be2\u8bbf\u95eeweb01\u548cweb02
\n\"\"
\n\"\"
\n\u767b\u5f55haproxy\u7684\u540e\u53f0
\n\"\"
\n\u53ef\u4ee5\u770b\u5230\u8bbf\u95eeweb01\u548cweb02\u7684\u76f8\u5173\u7edf\u8ba1\u6570\u636e
\n\"\"
\n\u4fee\u6539haproxy\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5c06web01\u7684\u6743\u91cd\u6539\u4e3a3\uff0cweb02\u7684\u6743\u91cd\u4ecd\u4e3a1\uff0c\u8fd9\u6837\u8bbf\u95ee\u5230\u4e24\u53f0web\u7684\u6bd4\u4f8b\u5e94\u8be5\u4e3a3:1\uff0c\u6539\u597d\u540e\u91cd\u542f\u4e0bhaproxy\u670d\u52a1
\n\"\"
\n\u518d\u6b21\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eeHAProxy\u7684IP\u5730\u5740\uff0c\u591a\u6b21\u5237\u65b0\u8fdb\u884c\u8bbf\u95ee\u6d4b\u8bd5
\n\u518d\u6b21\u767b\u5f55HAProxy\u540e\u53f0\u67e5\u770b\u7edf\u8ba1\u6570\u636e\uff0c\u53ef\u4ee5\u770b\u5230\u8bbf\u95ee\u5230web01\u548cweb02\u7684\u6bd4\u4f8b\u4e3a3:1
\n\"\"<\/p>\n

\u56db\u3001\u914d\u7f6eHAProxy\u4f7f\u7528Https\u52a0\u5bc6\u8bbf\u95ee<\/strong><\/div>\n

\u91c7\u7528\u5ba2\u6237\u7aef\u5230HAProxy\u4f7f\u7528https\u3001HAProxy\u5230WEB\u7aef\u4f7f\u7528http\u7684\u65b9\u5f0f\uff0c\u53ea\u9700\u8981\u5728HAProxy\u4e0a\u914d\u7f6e\u8bc1\u4e66\uff0c\u8fd9\u91cc\u6211\u4eec\u5c31\u914d\u7f6e\u4e00\u5f20\u81ea\u7b7e\u540d\u8bc1\u4e66\u6765\u6d4b\u8bd5\u4e00\u4e0b
\n\"\"
\n\u67e5\u770b\u4e00\u4e0b\u914d\u7f6e\u597d\u7684\u8bc1\u4e66jiangjianlong.pem
\n\"\"
\n\u4fee\u6539HAProxy\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u589e\u52a0\u4ee5\u4e0b\u53c2\u6570\u540e\u91cd\u542fhaproxy\u670d\u52a1
\n\"\"
\n\u4f7f\u7528https\u534f\u8bae\u8bbf\u95eeHAProxy\u7684IP\u5730\u5740\uff0c\u63d0\u793a\u8bc1\u4e66\u5b58\u5728\u95ee\u9898\uff0c\u8fd9\u662f\u56e0\u4e3a\u81ea\u7b7e\u540d\u8bc1\u4e66\u4e0d\u53d7\u6d4f\u89c8\u5668\u4fe1\u4efb\uff0c\u4f46\u8bf4\u660e\u4e0a\u6587\u914d\u7f6e\u7684\u8bc1\u4e66\u5df2\u7ecf\u751f\u6548\u4e86\uff0c\u70b9\u51fb\u7ee7\u7eed\u6d4f\u89c8\u6b64\u7f51\u7ad9
\n\"\"
\n\u6210\u529f\u8bbf\u95ee\u5230Web01\u9875\u9762\uff0c\u5237\u65b0\u4e5f\u80fd\u8bbf\u95ee\u5230Web02,\u8bf4\u660e\u5728https\u7684\u52a0\u5bc6\u8bbf\u95ee\u4e0b\u8d1f\u8f7d\u5747\u8861\u4e5f\u6ca1\u95ee\u9898
\n\"\"
\n\"\"
\n\u901a\u8fc7hosts\u89e3\u6790\u914d\u7f6e\u4e00\u4e2a\u57df\u540d\u6307\u5411HAProxy\u7684IP\u5730\u5740\uff0c\u4e5f\u80fd\u6b63\u5e38\u8bbf\u95ee
\n\"\"
\n\u67e5\u770b\u4e0b\u8bc1\u4e66\u4fe1\u606f\uff0c\u8ddf\u6211\u4eec\u521b\u5efa\u7684\u8bc1\u4e66\u4fe1\u606f\u4e00\u81f4
\n\"\"
\n\"\"
\n\u914d\u7f6ehttp\u91cd\u5b9a\u5411\uff0c\u81ea\u52a8\u5c06http\u91cd\u5b9a\u5411\u4e3ahttps,\u4fee\u6539haproxy\u914d\u7f6e\u6587\u4ef6\uff0c\u589e\u52a0\u4ee5\u4e0b\u53c2\u6570\uff0c\u5e76\u91cd\u542f\u670d\u52a1
\n\"\"
\n\u4f7f\u7528\u6d4f\u89c8\u5668\u6d4b\u8bd5\uff0c\u6210\u529f\u5b9e\u73b0http\u81ea\u52a8\u91cd\u5b9a\u5411\u4e3ahttps\u8fdb\u884c\u8bbf\u95ee\uff0c\u4f46\u7531\u4e8e\u622a\u56fe\u65e0\u6cd5\u5448\u73b0\u8fd9\u4e2a\u52a8\u6001\u7684\u6548\u679c\uff0c\u5c31\u4e0d\u622a\u4e86\u3002<\/p>\n

\u4e94\u3001\u914d\u7f6eHAProxy\u4f7f\u7528\u72ec\u7acb\u65e5\u5fd7\u6587\u4ef6<\/strong><\/div>\n

1\u3001HAProxy\u7684\u65e5\u5fd7\u9ed8\u8ba4\u5199\u5165\u5230\u7cfb\u7edf\u65e5\u5fd7\u4e2d\u53bb\uff0c\u6211\u4eec\u53ef\u4ee5\u628a\u5b83\u72ec\u7acb\u51fa\u6765\uff0c\u65b9\u4fbf\u6392\u67e5\u7ba1\u7406\u3002\u7f16\u8f91\/etc\/rsyslog.conf\uff0c\u6309\u4e0b\u56fe\u8fdb\u884c\u4fee\u6539
\n\"\"
\n\"\"
\n2\u3001\u91cd\u542frsyslog\u670d\u52a1\uff0c\u518d\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u4e00\u4e0bweb\u4ee5\u4fbf\u4ea7\u751f\u65e5\u5fd7\uff0c\u7136\u540e\u67e5\u770b\/var\/log\/haproxy.log\uff0c\u53d1\u73b0\u65e5\u5fd7\u5df2\u7ecf\u6309\u7167\u6211\u4eec\u4e0a\u6587\u6240\u914d\u7f6e\u7684\u90a3\u6837\uff0c\u8bb0\u5f55\u5230\/var\/log\/haproxy.log\u6765\u4e86
\n\"\"<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/jiangjianlong.blog.51cto.com\/3735273\/1887279<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/redhat7-haproxy-weblb.html<\/a>\u7f16\u8f91\uff1a\u70e8\u5b50\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u672c\u6587\u5c06\u7b80\u5355\u4ecb\u7ecd\u4f7f\u7528HAProxy\u5b9e\u73b0web\u8d1f\u8f7d\u5747\u8861\uff0c\u4e3b\u8981\u5185\u5bb9\u5305\u62ec\u57fa\u4e8e\u6743\u91cd\u7684\u8f6e\u8be2\u3001\u4e3aHAProxy\u914d\u7f6eht […]<\/p>\n","protected":false},"author":63,"featured_media":12142,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-46533","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/46533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=46533"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/46533\/revisions"}],"predecessor-version":[{"id":270294,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/46533\/revisions\/270294"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/12142"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=46533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=46533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=46533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}