{"id":13994,"date":"2023-07-24T09:16:36","date_gmt":"2023-07-24T01:16:36","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=13994"},"modified":"2023-07-26T13:56:44","modified_gmt":"2023-07-26T05:56:44","slug":"nginx-9","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2023\/07\/24\/nginx-9\/","title":{"rendered":"Nginx\u5065\u5eb7\u68c0\u67e5"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Nginx\u5065\u5eb7\u68c0\u67e5\u5206\u4e3a\u4e3b\u52a8\u548c\u88ab\u52a8\u4e24\u79cd\uff0c\u81ea\u5e26\u7684\u5065\u5eb7\u68c0\u67e5\u6a21\u5757\u4e3a\u88ab\u52a8\u68c0\u67e5\uff0c\u4e3b\u52a8\u68c0\u67e5\u6a21\u5757\u9700\u8981\u4f9d\u8d56\u7b2c\u4e09\u65b9\u6a21\u5757<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4e00\u3001\u88ab\u52a8\u5065\u5eb7\u68c0\u67e5<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u88ab\u52a8\u68c0\u67e5\u5c31\u662f\u53ea\u6709\u5f53Nginx\u8bbf\u95ee\u540e\uff0c\u624d\u4f1a\u53d1\u8d77\u5bf9\u540e\u7aef\u7684\u8282\u70b9\u63a2\u6d4b\uff0c\u8fd9\u6837\u5c31\u65e0\u6cd5\u9884\u5148\u5224\u65ad\u540e\u7aef\u670d\u52a1\u662f\u5426\u6b63\u5e38<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u81ea\u5e26\u7684\u5065\u5eb7\u68c0\u67e5\u6a21\u5757ngx_http_upstream_module\uff0c\u53ef\u5b9e\u73b0\u57fa\u672c\u5065\u5eb7\u68c0\u67e5\uff0c\u4e3b\u8981\u901a\u8fc7\u5982\u4e0b\u4e24\u4e2a\u53c2\u6570\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>max_fails\uff1a\u5141\u8bb8\u8bf7\u6c42\u5931\u8d25\u7684\u6b21\u6570\uff0c\u9ed8\u8ba4\u4e3a1<\/li>\n\n\n\n<li>fail_timeout\uff1a\u5982\u679c\u8fbe\u5230\u4e86max_fails\u7684\u5931\u8d25\u6b21\u6570\uff0c\u5c06\u6682\u505c\u540e\u7aef\u670d\u52a1\u7684\u65f6\u95f4\uff0c\u9ed8\u8ba4\u4e3a10s<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u4e0b\u9762\u4f8b\u5b50\u901a\u8fc7\u53cd\u5411\u4ee3\u7406\u5230tomcat\u548chttpd \uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"317\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/1-5.png\" alt=\"\" class=\"wp-image-14003\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/1-5.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/1-5-300x135.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/1-5-600x269.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u53cd\u5411\u4ee3\u7406\u8bf7\u6c42server-proxy\u4e2d\u7684\u670d\u52a1\uff0c\u5982\u679c\u5931\u8d25\u4e00\u6b21\uff0c\u90a3\u4e48\u5c06\u505c\u6b62\u8fd9\u4e2aserver\u63d0\u4f9b\u670d\u52a110s\u949f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u65f6\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/10.9.2.247\u5c06\u4f1a\u4ee5\u8f6e\u8be2\u7684\u65b9\u5f0f\u5206\u522b\u8bf7\u6c42tomcat\u548chttp\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"178\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/3-7.png\" alt=\"\" class=\"wp-image-14006\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/3-7.png 705w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/3-7-300x76.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/3-7-600x151.png 600w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"177\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/4-5.png\" alt=\"\" class=\"wp-image-14007\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/4-5.png 703w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/4-5-300x76.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/4-5-600x151.png 600w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u73b0\u5728\u5c06httpd\u5173\u95ed\uff0c\u7136\u540e\u518d\u6b21\u901a\u8fc7\u6d4f\u89c8\u5668\u591a\u6b21\u8bf7\u6c42\u53ef\u4ee5\u53d1\u73b0\u6b64\u65f6\u4e00\u76f4\u8bf7\u6c42\u7684\u662ftomcat\u9875\u9762\uff0c\u67e5\u770berror\u65e5\u5fd7\uff0c\u53ef\u4ee5\u53d1\u73b0\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2023\/07\/24 11:04:23 &#91;error] 59839#59839: *552 connect() failed (111: Connection refused) while connecting to upstream, client: 10.9.2.99, server: _, request: \"GET \/ HTTP\/1.1\", upstream: \"http:\/\/10.9.2.247:88\/\", host: \"10.9.2.247\"\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u4e0a\u8ff0\u9519\u8bef\u53ef\u4ee5\u770b\u51fa\uff0c\u867d\u7136\u9875\u9762\u8bf7\u6c42\u4e00\u76f4\u662f\u6b63\u5e38\u7684\uff0c\u4f46\u5b9e\u9645\u5728\u8bf7\u6c42\u8fc7\u7a0b\u4e2d\u8fd8\u662f\u4f1a\u8bf7\u6c42\u5230\u5df2\u7ecf\u4e0d\u80fd\u63d0\u4f9b\u670d\u52a1\u7684httpd\u4e0a\uff0c\u8fd9\u6837\u5c31\u4f1a\u9020\u6210\u4e00\u5b9a\u7684\u6027\u80fd\u5f71\u54cd<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4e8c\u3001\u4e3b\u52a8\u68c0\u67e5<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3b\u52a8\u5065\u5eb7\u68c0\u67e5\u9700\u8981\u501f\u52a9\u7b2c\u4e09\u65b9\u6a21\u5757nginx_upstream_check_module\uff0c\u6b64\u65f6nginx\u4f1a\u52a8\u6001\u63a2\u6d4b\u540e\u7aef\u670d\u52a1\uff0c\u5982\u679c\u670d\u52a1\u51fa\u73b0\u5f02\u5e38\uff0c\u90a3\u4e48\u5c06\u8be5\u670d\u52a1\u4ece\u5065\u5eb7\u5217\u8868\u4e2d\u79fb\u9664\uff0c\u670d\u52a1\u6062\u590d\u540e\u518d\u6b21\u5c06\u8be5\u670d\u52a1\u6dfb\u52a0\u56de\u5065\u5eb7\u5217\u8868\u4e2d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u4e0b\u8f7dnginx_upstream_check_module\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/github.com\/yaoweibin\/nginx_upstream_check_module\/archive\/master.zip\nunzip master.zip<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u4e0b\u8f7dNginx\uff0c\u5c06\u5176\u548c\u6a21\u5757nginx_upstream_check_module\u653e\u5728\u540c\u4e00\u7ea7\u76ee\u5f55\u4e0b\u5e76\u89e3\u538b\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>unzip nginx-1.24.0.tar.gz<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u8fdb\u5165nginx\u6e90\u7801\u76ee\u5f55\uff0c\u5c06nginx_upstream_check_module\u6a21\u5757\u4f5c\u4e3a\u8865\u4e01\u6253\u5165\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#-p0\u8868\u793a\u5f53\u524d\u8def\u5f84\uff0c-p1\u8868\u793a\u4e0a\u4e00\u7ea7\u8def\u5f84\npatch -p1 &lt; ..\/nginx_upstream_check_module-master\/check_1.20.1+.patch\n#\u6ce8\u610f\uff1acheck\u7248\u672c\u548cNginx\u7248\u672c\u8981\u6c42\u6709\u663e\u793a\uff0c\u53ef\u53c2\u8003https:\/\/github.com\/yaoweibin\/nginx_upstream_check_module<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u7f16\u8bd1\u5b89\u88c5Nginx\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd nginx-1.24.0\n.\/configure --prefix=\/usr\/local\/nginx --add-module=..\/nginx_upstream_check_module-master\nmake &amp;&amp; make install<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5\u3001\u7f16\u8f91nginx.conf\u6587\u4ef6\uff0c\u542f\u7528\u6a21\u5757\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"307\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/5-6.png\" alt=\"\" class=\"wp-image-14028\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/5-6.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/5-6-300x130.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/5-6-600x261.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>interval\uff1a\u6bcf\u4e2a3000ms\u6267\u884c\u4e00\u6b21\u5065\u5eb7\u68c0\u67e5\uff0c\u4e5f\u5c31\u662f3s<\/li>\n\n\n\n<li>rise\uff1a\u5982\u679c\u67092\u6b21\u5065\u5eb7\u68c0\u67e5\u7ed3\u679c\u4e3a\u6210\u529f\uff0c\u8868\u793a\u670d\u52a1\u72b6\u6001\u6b63\u5e38<\/li>\n\n\n\n<li>fall\uff1a\u5982\u679c\u67095\u6b21\u5065\u5eb7\u68c0\u67e5\u5931\u8d25\uff0c\u8868\u793a\u670d\u52a1\u72b6\u6001\u5f02\u5e38<\/li>\n\n\n\n<li>timeout\uff1a\u5065\u5eb7\u68c0\u67e5\u8d85\u65f6\u65f6\u95f4\u4e3a1000ms\uff0c\u4e5f\u5c31\u662f1s<\/li>\n\n\n\n<li>type : \u4f7f\u7528http\u7c7b\u578b\u7684\u5065\u5eb7\u68c0\u67e5<\/li>\n\n\n\n<li>check_http_send\uff1a\u53d1\u9001\u4e00\u4e2aHTTP HEAD\u8bf7\u6c42\uff0c\u534f\u8bae\u4e3a1.0<\/li>\n\n\n\n<li>\\r\\n &#8211; HTTP \u8bf7\u6c42\u7684\u6807\u51c6\u6362\u884c\u683c\u5f0f<\/li>\n\n\n\n<li>\\r\\n &#8211; \u8868\u793a\u7a7a\u884c,\u5206\u5272 HTTP \u8bf7\u6c42\u5934\u548c body<\/li>\n\n\n\n<li>&nbsp;check_http_expect_alive : \u671f\u671b\u8fd4\u56de 2xx \u6216 3xx \u72b6\u6001\u7801,\u8868\u793a\u670d\u52a1\u5668\u5b58\u6d3b<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u524d\u72b6\u6001\u4e5f\u662f\u8f6e\u8be2\u72b6\u6001\uff0c\u56e0\u6b64\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/10.9.2.247\u540e\u5c06\u5728tomcat\u548chttpd\u9875\u9762\u4e4b\u95f4\u8f6e\u8be2\uff0c\u8ddf\u4e0a\u9762\u4e00\u6837\uff0c\u73b0\u5728\u6211\u4eec\u624b\u52a8\u5173\u95edhttpd\uff0c\u7136\u540e\u89c2\u5bdfnginx\u7684error.log\uff0c\u53ef\u4ee5\u770b\u5230\u540e\u53f0\u5df2\u7ecf\u5f00\u59cb\u63d0\u793a\u670d\u52a1\u4e0d\u53ef\u7528\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"706\" height=\"198\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/6-5.png\" alt=\"\" class=\"wp-image-14036\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/6-5.png 706w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/6-5-300x84.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/6-5-600x168.png 600w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u65f6nginx\u5df2\u7ecf\u5c06\u8fd9\u4e2a\u670d\u52a1\u4ece\u540e\u7aef\u5265\u79bb\uff0c\u6b64\u65f6\u901a\u8fc7\u9875\u9762\u8bf7\u6c42\uff0c\u770b\u4e0d\u5230\u4efb\u4f55\u8bf7\u6c42\u53d1\u9001\u5230httpd<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6\u3001\u914d\u7f6e\u72b6\u6001\u68c0\u67e5\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"159\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/7-5.png\" alt=\"\" class=\"wp-image-14040\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/7-5.png 705w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/7-5-300x68.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/7-5-600x135.png 600w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u52a0\u8f7dNginx\u914d\u7f6e\u540e\uff0c\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/10.9.2.247\/status\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"704\" height=\"269\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/8-5.png\" alt=\"\" class=\"wp-image-14041\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/8-5.png 704w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/8-5-300x115.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/8-5-600x229.png 600w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u9644\u52a0\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u914d\u7f6e\u53cd\u5411\u4ee3\u7406\u7528\u7684\u540d\u5b57\u662fserver-proxy\uff0c\u5982\u679c\u4e0d\u5c0f\u5fc3\u5199\u6210server_proxy\uff0c\u90a3\u4e48\u5c06\u4f1a\u62a5\u9519\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"195\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/2-6.png\" alt=\"\" class=\"wp-image-14043\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/2-6.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/2-6-300x83.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/2-6-600x165.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u56e0\u6b64\uff0c\u53cd\u5411\u4ee3\u7406\u540d\u5b57\u4e0d\u8981\u7528\u4e0b\u6a2a\u6760\uff0c\u5426\u5219\u4f1a\u62a5\u9519<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9664\u4e86\u4e0a\u9762\u6a21\u5757\u5916\uff0c\u8fd8\u6709\u4e00\u4e2a\u6a21\u5757\u53ef\u5b9e\u73b0\u56db\u5c42\u548c7\u5c42\u7684\u68c0\u67e5\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;github.com\/zhouchangxun\/ngx_healthcheck_module\/blob\/master\/README-zh_CN.md<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Nginx\u5065\u5eb7\u68c0\u67e5\u5206\u4e3a\u4e3b\u52a8\u548c\u88ab\u52a8\u4e24\u79cd\uff0c\u81ea\u5e26\u7684\u5065\u5eb7\u68c0\u67e5\u6a21\u5757\u4e3a\u88ab\u52a8\u68c0\u67e5\uff0c\u4e3b\u52a8\u68c0\u67e5\u6a21\u5757\u9700\u8981\u4f9d\u8d56\u7b2c\u4e09\u65b9\u6a21\u5757 \u4e00\u3001\u88ab\u52a8\u5065 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":13995,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,22],"tags":[],"class_list":["post-13994","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-server"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=13994"}],"version-history":[{"count":39,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13994\/revisions"}],"predecessor-version":[{"id":14160,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/13994\/revisions\/14160"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/13995"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=13994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=13994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=13994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}