{"id":1009,"date":"2023-05-28T02:28:45","date_gmt":"2023-05-27T18:28:45","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=1009"},"modified":"2023-05-28T02:28:45","modified_gmt":"2023-05-27T18:28:45","slug":"08-nginx%e5%9b%9b%e5%b1%82%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/nginx\/08-nginx%e5%9b%9b%e5%b1%82%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1\/","title":{"rendered":"08-Nginx\u56db\u5c42\u8d1f\u8f7d\u5747\u8861"},"content":{"rendered":"<div class='wxsyncmain'>\n<section data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\" style=\"font-size: 16px;color: black;padding-right: 10px;padding-left: 10px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;\">\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;font-size: 20px;\"><span style=\"display: none;\"><\/span>1\u3001Nginx\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u57fa\u672c\u6982\u8bc9<span style=\"display: none;\"><\/span><\/h3>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;\"><span style=\"display: none;\"><\/span>(1) \u4ec0\u4e48\u662f\u56db\u5c42\u8d1f\u8f7d\u5747\u8861<span style=\"display: none;\"><\/span><\/h5>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"border-top: none;border-right: none;border-bottom: none;font-size: 0.9em;overflow: auto;border-left-color: rgba(0, 0, 0, 0.4);background: rgba(0, 0, 0, 0.05);color: rgb(106, 115, 125);padding: 10px 10px 10px 20px;margin-bottom: 20px;margin-top: 20px;\">\n<p style=\"font-size: 16px;padding-top: 8px;padding-bottom: 8px;color: black;line-height: 26px;\">\u2002\u2002\u2002\u2002\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u57fa\u4e8e\u4f20\u8f93\u5c42\u534f\u8bae\u5305\u6765\u5c01\u88c5\u7684\uff08\u5982\uff1aTCP\/IP\uff09\uff0c\u90a3\u6211\u4eec\u524d\u9762\u4f7f\u7528\u5230\u7684\u4e03\u5c42\u6307\u7684\u662f\u5e94\u7528\u5c42\uff0c\u5b83\u7684\u5c01\u88c5\u5728\u56db\u5c42\u57fa\u7840\u4e4b\u4e0a\uff0c\u65e0\u8bba\u56db\u5c42\u8fd8\u662f\u4e03\u5c42\u90fd\u6307\u7684\u662fOSI\u7f51\u7edc\u6a21\u578b\u3002<\/p>\n<\/blockquote>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;\"><span style=\"display: none;\"><\/span>(2) \u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u5e94\u7528\u573a\u666f<span style=\"display: none;\"><\/span><\/h5>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"border-top: none;border-right: none;border-bottom: none;font-size: 0.9em;overflow: auto;border-left-color: rgba(0, 0, 0, 0.4);background: rgba(0, 0, 0, 0.05);color: rgb(106, 115, 125);padding: 10px 10px 10px 20px;margin-bottom: 20px;margin-top: 20px;\">\n<p style=\"font-size: 16px;padding-top: 8px;padding-bottom: 8px;color: black;line-height: 26px;\">1.<code style=\"font-size: 14px;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;\">\u56db\u5c42\u8d1f\u8f7d<\/code>\u53ef\u4ee5\u4fdd\u8bc17\u5c42\u8d1f\u8f7d\u7684\u9ad8\u53ef\u7528\uff1a\u56db\u5c42+\u4e03\u5c42\u6765\u505a\u8d1f\u8f7d\u5747\u8861\uff0c\u56db\u5c42\u53ef\u4ee5\u4fdd\u8bc1\u4e03\u5c42\u7684\u8d1f\u8f7d\u5747\u8861\u7684\u9ad8\u53ef\u7528\u6027\uff0c\u5982\uff1anginx\u5c31\u65e0\u6cd5\u4fdd\u8bc1\u81ea\u5df1\u7684\u670d\u52a1\u9ad8\u53ef\u7528\uff0c\u9700\u8981\u4f9d\u8d56LVS\u6216\u8005keepaive\u3002<br  \/>2\u3001\u7aef\u53e3\u6620\u5c04\uff08\u7aef\u53e3\u8f6c\u53d1\uff09\uff1a\u5982\uff1aTCP\u534f\u8bae\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u6709\u4e9b\u8bf7\u6c42\u662fTCP\u534f\u8bae\u7684\uff08mysql\uff0cssh\uff09\uff0c\u6216\u8005\u8bf4\u8fd9\u4e9b\u8bf7\u6c42\u53ea\u9700\u8981\u4f7f\u7528\u56db\u5c42\u8fdb\u884c\u7aef\u53e3\u7684\u8f6c\u53d1\u5c31\u53ef\u4ee5\u4e86\uff0c\u6240\u4ee5\u4f7f\u7528\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n<\/blockquote>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;\"><span style=\"display: none;\"><\/span>(3) \u56db\u5c42+\u4e03\u5c42\u6784\u5efa\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u4f7f\u7528\u573a\u666f<span style=\"display: none;\"><\/span><\/h5>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"lazyload\"data-ratio=\"0.3416149068322981\" data-type=\"jpeg\" data-w=\"805\" style=\"display: block;margin-right: auto;margin-left: auto;height: auto !important;\"  data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021800282.jpeg\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"  \/><noscript><img decoding=\"async\" data-ratio=\"0.3416149068322981\" data-type=\"jpeg\" data-w=\"805\" style=\"display: block;margin-right: auto;margin-left: auto;height: auto !important;\"  src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021800282.jpeg\"  \/><\/noscript><\/figure>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;\"><span style=\"display: none;\"><\/span>(4) \u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u603b\u7ed3<span style=\"display: none;\"><\/span><\/h5>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"border-top: none;border-right: none;border-bottom: none;font-size: 0.9em;overflow: auto;border-left-color: rgba(0, 0, 0, 0.4);background: rgba(0, 0, 0, 0.05);color: rgb(106, 115, 125);padding: 10px 10px 10px 20px;margin-bottom: 20px;margin-top: 20px;\">\n<p style=\"font-size: 16px;padding-top: 8px;padding-bottom: 8px;color: black;line-height: 26px;\">1\u3001\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u4ec5\u80fd\u8f6c\u53d1TCP\/IP\u534f\u8bae\u3001UDP\u534f\u8bae\u3001\u901a\u5e38\u7528\u6765\u8f6c\u53d1\u7aef\u53e3\uff0c\u5982\uff1atcp\/22\u3001udp\/53<br  \/>2\u3001\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u53ef\u4ee5\u7528\u6765\u89e3\u51b3\u4e03\u5c42\u8d1f\u8f7d\u5747\u8861\u7aef\u53e3\u9650\u5236\u95ee\u9898\uff1b\uff08\u4e03\u5c42\u8d1f\u8f7d\u5747\u8861\u6700\u5927\u4f7f\u752865535\u4e2a\u7aef\u53e3\uff09<br  \/>3\u3001\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u53ef\u4ee5\u89e3\u51b3\u4e03\u5c42\u8d1f\u8f7d\u5747\u8861\u9ad8\u53ef\u7528\u95ee\u9898;\uff08\u591a\u53f0\u540e\u7aef\u4e03\u5c42\u8d1f\u8f7d\u5747\u8861\u80fd\u540c\u65f6\u7684\u4f7f\u7528\uff09<br  \/>4\u3001\u56db\u5c42\u7684\u8f6c\u53d1\u6548\u7387\u6bd4\u4e03\u5c42\u7684\u9ad8\u5f97\u591a\uff0c\u4f46\u4ec5\u652f\u6301tcp\/ip\u534f\u8bae\uff0c\u4e0d\u652f\u6301http\u548chttps\u534f\u8bae\uff1b<br  \/>5\u3001\u901a\u5e38\u5927\u5e76\u53d1\u573a\u666f\u901a\u5e38\u4f1a\u9009\u62e9\u4f7f\u7528\u5728\u4e03\u5c42\u8d1f\u8f7d\u5747\u8861\u524d\u9762\u589e\u52a0\u56db\u5c42\u8d1f\u8f7d\u5747\u8861<br  \/><\/p>\n<\/blockquote>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;font-size: 20px;\"><span style=\"display: none;\"><\/span>2\u3001Nginx\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u5b9e\u6218<span style=\"display: none;\"><\/span><\/h3>\n<h5 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;\"><span style=\"display: none;\"><\/span>(1) Nginx\u56db\u5c42\u8d1f\u8f7d\u8bed\u6cd5<span style=\"display: none;\"><\/span><\/h5>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block;background: url(&quot;https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021801513.jpeg&quot;) 10px 10px \/ 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;\"><\/span><code style=\"overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;\">[root@4-Proxy1-10&nbsp;~]<span style=\"color: #5c6370;font-style: italic;line-height: 26px;\">#&nbsp;cat&nbsp;\/etc\/nginx\/conf.c\/tcp_proxy.conf<\/span><br  \/>stream&nbsp;{<br  \/><br  \/><span style=\"color: #5c6370;font-style: italic;line-height: 26px;\">#\u5b9a\u4e49\u65e5\u5fd7\u7684\u683c\u5f0f<\/span><br  \/>log_format&nbsp;&nbsp;proxy&nbsp;<span style=\"color: #98c379;line-height: 26px;\">'$remote_addr&nbsp;$remote_port&nbsp;-&nbsp;[$time_local]&nbsp;$status&nbsp;$protocol&nbsp;'<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #98c379;line-height: 26px;\">'\"$upstream_addr\"&nbsp;\"$upstream_bytes_sent\"&nbsp;\"$upstream_connect_time\"'<\/span>&nbsp;;<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #5c6370;font-style: italic;line-height: 26px;\">#\u8c03\u7528\u65e5\u5fd7\uff0c\u4f7f\u7528proxy\u683c\u5f0f<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;access_log&nbsp;\/var\/<span style=\"color: #e6c07b;line-height: 26px;\">log<\/span>\/nginx\/tcp_proxy.log&nbsp;proxy;<br  \/><br  \/>......\u5176\u4ed6\u914d\u7f6e\u7701\u7565......<br  \/><br  \/><span style=\"color: #5c6370;font-style: italic;line-height: 26px;\">#\u67e5\u770b\u65e5\u5fd7&nbsp;tail&nbsp;-f&nbsp;\/var\/log\/nginx\/tcp_proxy.log&nbsp;\u53ef\u4ee5\u770b\u89c1\u65e5\u5fd7<\/span><br  \/>}<br  \/><\/code><\/pre>\n<\/section>\n<p><br  \/><\/p>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 \u8fd0\u7ef4\u5e93              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>1\u3001Nginx\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u57fa\u672c\u6982\u8bc9 (1) \u4ec0\u4e48\u662f\u56db\u5c42\u8d1f\u8f7d\u5747\u8861 \u2002\u2002\u2002\u2002\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u57fa\u4e8e\u4f20\u8f93\u5c42\u534f\u8bae\u5305\u6765\u5c01\u88c5\u7684\uff08\u5982\uff1aTCP\/IP\uff09\uff0c &#8230;<\/p>\n","protected":false},"author":1,"featured_media":1006,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[5],"tags":[],"class_list":["post-1009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021759850-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021800282.jpeg","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021759850-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021759850.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021800282.jpeg","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021759850-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021759850.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021759850.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021800282.jpeg","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528021800282.jpeg","id":"image1"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Nginx","post_date":"2023-05-27","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":310,"next_post_id":1880,"next_post_title":"\u6027\u80fd\u5206\u6790-Nginx\u542f\u52a8gzip","previous_post_id":351,"previous_post_title":"Nginx\u4e00\u7f51\u6253\u5c3d\uff1a\u52a8\u9759\u5206\u79bb\u3001\u538b\u7f29\u3001\u7f13\u5b58\u3001\u9ed1\u767d\u540d\u5355\u3001\u8de8\u57df\u3001\u9ad8\u53ef\u7528\u3001\u6027\u80fd\u4f18\u5316...","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/1009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1009"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/1009\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/1006"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}