{"id":18649,"date":"2024-11-19T20:38:53","date_gmt":"2024-11-19T12:38:53","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=18649"},"modified":"2024-11-19T20:38:53","modified_gmt":"2024-11-19T12:38:53","slug":"haproxy%e4%b8%ad%e5%87%a0%e7%a7%8d%e5%81%a5%e5%ba%b7%e6%a3%80%e6%9f%a5%e7%9a%84%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18649\/","title":{"rendered":"Haproxy\u4e2d\u51e0\u79cd\u5065\u5eb7\u68c0\u67e5\u7684\u4f7f\u7528"},"content":{"rendered":"<p>\u5728Haproxy\u4e2d\u6709httpchk\u3001ssl-hello-chk<\/p>\n<p>\u4e0b\u9762\u6765\u9010\u4e2a\u4ecb\u7ecd\u4e0b\u8fd9\u51e0\u79cd\u5065\u5eb7\u68c0\u67e5\u7684\u4f7f\u7528\uff0c\u4e86\u89e3\u4e86\u8fd9\u4e9b\u5c31\u5e94\u8be5\u6e05\u695a\u77e5\u9053\u600e\u4e48\u8bbe\u7f6ehaproxy\u5bf9\u540e\u7aef\u670d\u52a1\u7684\u68c0\u67e5\u68c0\u67e5\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>\u4e00\u3001option httpchk<\/h1>\n<p>\u4ece\u5b57\u9762\u7406\u89e3\uff0c\u6211\u90fd\u80fd\u77e5\u9053\u5927\u6982\u542b\u4e49\uff0chttp check\uff0c\u6ca1\u9519\uff0c\u8fd9\u4e2a\u8bbe\u7f6e\u8868\u793a\u5f00\u542f\u540e\u7aef\u670d\u52a1\u5668\u7684http\u5065\u5eb7\u68c0\u67e5\u3002\u4e0b\u9762\u6765\u770b\u4e0b\u5728haproxy\u4e2d\u662f\u5982\u4f55\u8bbe\u7f6e\u7684\u3002<\/p>\n<p>\u901a\u7528\u683c\u5f0f\uff1a<\/p>\n<pre>option httpchk\r\noption httpchk &lt;uri&gt;\r\noption httpchk &lt;method&gt; &lt;uri&gt;\r\noption httpchk &lt;method&gt; &lt;uri&gt; &lt;version&gt;<\/pre>\n<p>\u5728default\u3001backend\u3001listen\u4f7f\u7528\uff0c\u7981\u6b62\u5728frontend\u4f7f\u7528\u3002<\/p>\n<p><strong>method\uff1a<\/strong>\u53ef\u4ee5\u6307\u5b9ahttp\u534f\u8bae\u4e2d\u7684\u65b9\u6cd5\uff0c\u53ef\u53c2\u8003\uff1aHTTP\u534f\u8bae\u4e2d\u768414\u79cd\u8bf7\u6c42\u65b9\u6cd5\uff0c\u9ed8\u8ba4\u4f7f\u7528 OPTIONS\uff0c\u7136\u4f7f\u7528OPTIONS\u00a0 \u5bf9\u540e\u7aef\u670d\u52a1\u5668\u7684\u6027\u80fd\u5f71\u54cd\u6700\u5c0f\u3002<\/p>\n<p><strong>uri\uff1a<\/strong>\u9ed8\u8ba4 \/ ,\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u6210\u5176\u4ed6\u7684\u5730\u5740\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528query\u7684\u683c\u5f0f\u3002<\/p>\n<p><strong>version\uff1a<\/strong>http\u7684\u534f\u8bae\u7248\u672c\uff0c\u53ef\u9009\u9879 HTTP\/1.0\u548cHTTP\/1.1\uff0c\u9ed8\u8ba4HTTP\/1.0\uff0c\u5728\u6709\u4e00\u4e9bweb\u670d\u52a1\u4e2d\uff0c\u9700\u8981\u52a0\u4e0aHOST\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u5728HTTP\/1.1\u540e\u9700\u8981\u52a0\u4e0a\/r\/n\u62fc\u63a5HOST\uff0c\u4f8b\u5982\uff1aHTTP\/1.1\\r\\nHost:www<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>option httpchk \/chk.html\r\noption httpchk OPTIONS \/chk.html\r\noption httpchk OPTIONS \/chk.html HTTP\/1.0\r\n\u4ee5\u4e0a\u4e09\u4e2a\u7b49\u540c\uff0c\u53ea\u662f\u5199\u6cd5\u4e0d\u4e00\u6837\u3002\r\n\r\noption httpchk OPTIONS \/index.php?abc=abc HTTP\/1.1\\r\\nHost:www<\/pre>\n<p><strong>Tips 1\uff1a<\/strong>\u4e4b\u524d\u548c\u4e00\u4e2a\u670b\u53cb\u5728\u8c08\u53ca\u8fd9\u4e2a\u95ee\u9898\u65f6\uff0c\u4ed6\u4f7f\u7528\u5982\u4e0b\u7684\u4ee3\u7801\u8bbe\u7f6e\uff1a<\/p>\n<pre>option  httpchk GET http:\/\/www.baidu.com\/ HTTP\/1.0\r\n\r\n\uff03\u8fd9\u4e2a\u8bbe\u7f6e\u7684\u4e5f\u641e\u4e0d\u6e05\u695a\uff0c\u539f\u7406\u662f\u4ec0\u4e48\uff1f\u8fd9\u4e2a\u8fd8\u4e0d\u7b97\u8be1\u5f02\uff0c\u66f4\u8be1\u5f02\u7684\u662f\uff1a\r\n\r\noption  httpchk GET abc:\/\/aaaaaaaaaaa HTTP\/1.0 \uff0c\u8fd9\u4e2a\u4f9d\u65e7\u53ef\u4ee5\u3002\u5728nginx\u7684\u65e5\u5fd7\u4e2d\uff0c\r\n\u4f9d\u65e7\u53ef\u4ee5\u770b\u5230\u8fd4\u56de200<\/pre>\n<p>\u4e8c\u3001option ssl-hello-chk<\/p>\n<p>check-ssl<\/p>\n<p>option tcp-check<\/p>\n<p>option redis-check<\/p>\n<p>option smtpchk<br \/>\noption smtpchk &lt;hello&gt; &lt;domain&gt;<\/p>\n<p>option mysql-check [ user &lt;username&gt; [ post-41 ] ]<\/p>\n<p>option pgsql-check [ user &lt;username&gt; ]<\/p>\n<p>http-check disable-on-404<\/p>\n<p>http-check expect [!] &lt;match&gt; &lt;pattern&gt;<\/p>\n<p>check-send-proxy<\/p>\n<p>inter &lt;delay&gt;<br \/>\nfastinter &lt;delay&gt;<br \/>\ndowninter &lt;delay&gt;<\/p>\n<p>timeout check &lt;timeout&gt;<\/p>\n<p>check<\/p>\n<p><strong>max-spread-checks &lt;delay in milliseconds&gt;<\/strong><br \/>\n<strong>spread-checks &lt;0..50, in percent&gt;<\/strong><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Haproxy\u4e2d\u6709httpchk\u3001ssl-hello-chk \u4e0b\u9762\u6765\u9010\u4e2a\u4ecb\u7ecd\u4e0b\u8fd9\u51e0\u79cd\u5065\u5eb7\u68c0\u67e5\u7684\u4f7f\u7528\uff0c\u4e86\u89e3\u4e86\u8fd9\u4e9b\u5c31\u5e94\u8be5\u6e05\u695a\u77e5\u9053\u600e\u4e48\u8bbe\u7f6ehaproxy\u5bf9\u540e\u7aef\u670d\u52a1\u7684\u68c0\u67e5\u68c0\u67e5\u4e86\u3002 &nbsp; \u4e00\u3001option httpchk \u4ece\u5b57\u9762\u7406\u89e3\uff0c\u6211\u90fd\u80fd\u77e5\u9053\u5927\u6982\u542b\u4e49\uff0chttp check\uff0c\u6ca1\u9519\uff0c\u8fd9\u4e2a\u8bbe\u7f6e\u8868\u793a\u5f00\u542f\u540e\u7aef\u670d\u52a1\u5668\u7684http\u5065\u5eb7\u68c0\u67e5\u3002\u4e0b\u9762\u6765\u770b\u4e0b\u5728haproxy\u4e2d\u662f\u5982\u4f55\u8bbe\u7f6e\u7684\u3002 \u901a\u7528\u683c\u5f0f\uff1a option httpchk option httpchk &lt;uri&gt; option httpchk &lt;method&gt; &lt;uri&gt; option httpchk &lt;method&gt; &lt;uri&gt; &lt;version&gt; \u5728default\u3001backend\u3001listen\u4f7f\u7528\uff0c\u7981\u6b62\u5728frontend\u4f7f\u7528\u3002 method\uff1a\u53ef\u4ee5\u6307\u5b9ahttp\u534f\u8bae\u4e2d\u7684\u65b9\u6cd5\uff0c\u53ef\u53c2\u8003\uff1aHTTP\u534f\u8bae\u4e2d\u768414\u79cd\u8bf7\u6c42\u65b9\u6cd5\uff0c\u9ed8\u8ba4\u4f7f\u7528 OPTIONS\uff0c\u7136\u4f7f\u7528OPTIONS\u00a0 \u5bf9\u540e\u7aef\u670d\u52a1\u5668\u7684\u6027\u80fd\u5f71\u54cd\u6700\u5c0f\u3002 uri\uff1a\u9ed8\u8ba4 \/ ,\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u6210\u5176\u4ed6\u7684\u5730\u5740\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528query\u7684\u683c\u5f0f\u3002 version\uff1ahttp\u7684\u534f\u8bae\u7248\u672c\uff0c\u53ef\u9009\u9879 HTTP\/1.0\u548cHTTP\/1.1\uff0c\u9ed8\u8ba4HTTP\/1.0\uff0c\u5728\u6709\u4e00\u4e9bweb\u670d\u52a1\u4e2d\uff0c\u9700\u8981\u52a0\u4e0aHOST\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u5728HTTP\/1.1\u540e\u9700\u8981\u52a0\u4e0a\/r\/n\u62fc\u63a5HOST\uff0c\u4f8b\u5982\uff1aHTTP\/1.1\\r\\nHost:www \u4f8b\u5982\uff1a option httpchk \/chk.html option httpchk OPTIONS \/chk.html option httpchk OPTIONS \/chk.html HTTP\/1.0 \u4ee5\u4e0a\u4e09\u4e2a\u7b49\u540c\uff0c\u53ea\u662f\u5199\u6cd5\u4e0d\u4e00\u6837\u3002 option httpchk OPTIONS \/index.php?abc=abc HTTP\/1.1\\r\\nHost:www Tips 1\uff1a\u4e4b\u524d\u548c\u4e00\u4e2a\u670b\u53cb\u5728\u8c08\u53ca\u8fd9\u4e2a\u95ee\u9898\u65f6\uff0c\u4ed6\u4f7f\u7528\u5982\u4e0b\u7684\u4ee3\u7801\u8bbe\u7f6e\uff1a option httpchk GET [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-18649","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18649"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18649\/revisions"}],"predecessor-version":[{"id":18650,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18649\/revisions\/18650"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}