{"id":62088,"date":"2025-04-29T14:17:17","date_gmt":"2025-04-29T06:17:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/62088\/"},"modified":"2025-04-29T14:17:17","modified_gmt":"2025-04-29T06:17:17","slug":"%e4%b8%80%e5%bc%a0%e5%b0%8f%e5%9b%be%e7%9c%8b%e5%b0%bd-nginx-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/62088\/","title":{"rendered":"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx"},"content":{"rendered":"<p> <\/p>\n<p style=\"text-align: center;margin-bottom: 0em\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/feee9238de7c24ccaa80f88042dd97ab-0.jpg\" class=\"aligncenter\" title=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe\" alt=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe\" \/><\/p>\n<p style=\"text-align: center;margin-bottom: 0em\"><\/p>\n<p style=\"margin: 0px 0px 0em;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/feee9238de7c24ccaa80f88042dd97ab-1.jpg\" class=\"aligncenter\" title=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe1\" alt=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe1\" \/><\/p>\n<h4><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\u5b89\u88c5<\/span><\/h4>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">Nginx\u5b89\u88c5\u5b8c\u6210\uff0c\u6ca1\u6709sbin\u76ee\u5f55<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">cd\u8fdb\u5165\u5230nginx-1.18.0\u76ee\u5f55\u5185\u6267\u884c<\/span><\/p>\n<pre>[root@centos7&nbsp;nginx-1.18.0]#&nbsp;.\/configure&nbsp;--prefix=\/usr\/local\/nginx[root@centos7&nbsp;nginx-1.18.0]#&nbsp;make[root@centos7&nbsp;nginx-1.18.0]#&nbsp;make&nbsp;install<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">ps\uff1a\u2013prefix=path \u5b9a\u4e49\u4e00\u4e2a\u76ee\u5f55\uff0c\u5b58\u653e\u670d\u52a1\u5668\u4e0a\u7684\u6587\u4ef6 \uff0c\u4e5f\u5c31\u662fnginx\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u9ed8\u8ba4\u4f7f\u7528 \/usr\/local\/nginx<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u8fd9\u6b65\u4f60\u4f1a\u770b\u5230local\u76ee\u5f55\u4e0b\u6709\u4e00\u4e2a\u8ddf\u4f60\u5b89\u88c5\u7684nginx1.12.2\u540c\u7ea7\u7684nginx\u76ee\u5f55\uff0c\u91cc\u9762\u5c31\u6709sbin\u76ee\u5f55\u4e86\u3002<\/span><\/p>\n<h4><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: inherit;color: inherit;line-height: inherit\">\u57fa\u7840\u6307\u4ee4<\/span><\/h4>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">listen\uff1a\u8be5\u6307\u4ee4\u7528\u4e8e\u914d\u7f6e\u7f51\u7edc\u76d1\u542c\u3002<\/span><\/p>\n<pre>listen&nbsp;*:80&nbsp;|&nbsp;*:8080&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u76d1\u542c\u6240\u670980\u7aef\u53e3\u548c8080\u7aef\u53e3listen&nbsp;&nbsp;IP_address:port&nbsp;&nbsp;&nbsp;#\u76d1\u542c\u6307\u5b9a\u7684\u5730\u5740\u548c\u7aef\u53e3\u53f7listen&nbsp;&nbsp;IP_address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u76d1\u542c\u6307\u5b9aip\u5730\u5740\u6240\u6709\u7aef\u53e3listen&nbsp;port&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u76d1\u542c\u8be5\u7aef\u53e3\u7684\u6240\u6709IP\u8fde\u63a5<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">server_name\uff1a\u8be5\u6307\u4ee4\u7528\u4e8e\u865a\u62df\u4e3b\u673a\u7684\u914d\u7f6e\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">a. \u57fa\u4e8e\u540d\u79f0\u7684\u865a\u62df\u4e3b\u673a\u914d\u7f6e<\/span><\/p>\n<pre>server_name&nbsp;&nbsp;&nbsp;name&nbsp;...;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">b. \u57fa\u4e8e IP \u5730\u5740\u7684\u865a\u62df\u4e3b\u673a\u914d\u7f6e<\/span><\/p>\n<pre>server_name&nbsp;192.168.1.1<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">location\uff1a\u8be5\u6307\u4ee4\u7528\u4e8e\u5339\u914d URL\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">location\u6307\u4ee4\u7684\u4f5c\u7528\u662f\u6839\u636e\u7528\u6237\u8bf7\u6c42\u7684URI\u6765\u6267\u884c\u4e0d\u540c\u7684\u5e94\u7528\uff0c\u4e5f\u5c31\u662f\u6839\u636e\u7528\u6237\u8bf7\u6c42\u7684\u7f51\u7ad9URL\u8fdb\u884c\u5339\u914d\uff0c\u5339\u914d\u6210\u529f\u5373\u8fdb\u884c\u76f8\u5173\u7684\u64cd\u4f5c\u3002<\/span><\/p>\n<pre>\u725b\u903c\u554a\uff01\u63a5\u79c1\u6d3b\u5fc5\u5907\u7684&nbsp;N&nbsp;\u4e2a\u5f00\u6e90\u9879\u76ee\uff01\u8d76\u5feb\u6536\u85cf\u5427<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">location\u7684\u8bed\u6cd5<\/span><\/p>\n<ul>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">=\u5f00\u5934\u8868\u793a\u7cbe\u786e\u5339\u914d<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\u5982 A \u4e2d\u53ea\u5339\u914d\u6839\u76ee\u5f55\u7ed3\u5c3e\u7684\u8bf7\u6c42\uff0c\u540e\u9762\u4e0d\u80fd\u5e26\u4efb\u4f55\u5b57\u7b26\u4e32\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">^~ \u5f00\u5934\u8868\u793auri\u4ee5\u67d0\u4e2a\u5e38\u89c4\u5b57\u7b26\u4e32\u5f00\u5934\uff0c\u4e0d\u662f\u6b63\u5219\u5339\u914d<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">~ \u5f00\u5934\u8868\u793a\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d;<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">~* \u5f00\u5934\u8868\u793a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\/ \u901a\u7528\u5339\u914d, \u5982\u679c\u6ca1\u6709\u5176\u5b83\u5339\u914d,\u4efb\u4f55\u8bf7\u6c42\u90fd\u4f1a\u5339\u914d\u5230<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">Location\u6b63\u5219\u6848\u4f8b<\/span><\/p>\n<pre>#\u7cbe\u786e\u5339\u914d,\/\u540e\u9762\u4e0d\u80fd\u5e26\u4efb\u4f55\u5b57\u7b26\nserver&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;www.itmayiedu.com;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u7cbe\u786e\u5339\u914d,\u6ce8\u89e3\u540e\u9762\u4e0d\u80fd\u5e26\u4efb\u4f55\u5b57\u7b26\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;=\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8080;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n\n&nbsp;#\u5339\u914d\u6240\u6709\u4ee5\/\u5f00\u5934\u8bf7\u6c42\nserver&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;www.itmayiedu.com;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u5339\u914d\u6240\u6709\u4ee5\/\u5f00\u5934\u8bf7\u6c42&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8080;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}\n###&nbsp;&nbsp;\u4ee5\u5f00\u5934\/itmayiedu_8080\u62e6\u622a&nbsp;&nbsp;\u9ed8\u8ba4\u5f00\u542f\u4e0d\u533a\u5206\u5927\u5c0f\u5199\n&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;www.itmayiedu.com;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;###&nbsp;&nbsp;\u4ee5\u5f00\u5934\/itmayiedu_8080&nbsp;\u6700\u7ec8\u8df3\u8f6c\u5230http:\/\/127.0.0.1:8080\/;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/itmayiedu_8080\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8080\/;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;###&nbsp;&nbsp;\u4ee5\u5f00\u5934\/itmayiedu_8080&nbsp;\u6700\u7ec8\u8df3\u8f6c\u5230http:\/\/127.0.0.1:8081\/;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/itmayiedu_8081\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8081\/;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}\n###&nbsp;\u5f00\u5934\u533a\u5206\u5927\u5c0f\u5199<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">proxy_pass\uff1a\u8be5\u6307\u4ee4\u7528\u4e8e\u8bbe\u7f6e\u88ab\u4ee3\u7406\u670d\u52a1\u5668\u7684\u5730\u5740\u3002\u53ef\u4ee5\u662f\u4e3b\u673a\u540d\u79f0\u3001IP\u5730\u5740\u52a0\u7aef\u53e3\u53f7\u7684\u5f62\u5f0f\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u8bed\u6cd5\u7ed3\u6784\u5982\u4e0b\uff1a<\/span><\/p>\n<pre>proxy_pass&nbsp;URL;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">index\uff1a\u8be5\u6307\u4ee4\u7528\u4e8e\u8bbe\u7f6e\u7f51\u7ad9\u7684\u9ed8\u8ba4\u9996\u9875\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u57df\u540d\u91cd\u5b9a\u5411<\/span><\/p>\n<pre>server\n{\n&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;80&nbsp;;\n&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;mxiaoqi.top&nbsp;aaa.com;\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;$host&nbsp;=&nbsp;mxiaoqi.top&nbsp;)\n&nbsp;&nbsp;&nbsp;&nbsp;#\u589e\u52a0\u5224\u65ad\u6761\u4ef6\uff0c\u5f53\u8bbf\u95ee\u57df\u540d\u662fmxiaoqi.top\u7684\u65f6\u5019\n&nbsp;&nbsp;&nbsp;&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite&nbsp;\/(.*)&nbsp;&nbsp;http:\/\/aaa.com\/$1&nbsp;permanent;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u628amxiaoqi.top\/\u540e\u9762\u7684\u5185\u5bb9\u91cd\u65b0\u5199\u5230aaa.com\/\u540e\u9762\u5982\u679c\u540e\u9762\u6709\u591a\u6bb5\u5219\u4f7f\u7528$2\u3001$3\u4ee5\u6b64\u7c7b\u63a8\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#permanent\u662f\u8f6c\u53d1\u72b6\u6001\u7801\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;index.html&nbsp;index.htm&nbsp;index.php;\n&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;\/data\/wwwroot\/mxiaoqi.top;\n&nbsp;&nbsp;&nbsp;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u53cd\u5411\u4ee3\u7406<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u4f7f\u7528 nginx \u53cd\u5411\u4ee3\u7406 www.123.com \u76f4\u63a5\u8df3\u8f6c\u5230127.0.0.1:8080<\/span><\/p>\n<pre>server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;www.123.com;\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8080;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6b22\u8fce\u9875\u9762\uff0c\u6309\u7167\u4ece\u5de6\u5230\u53f3\u7684\u987a\u5e8f\u67e5\u627e\u9875\u9762\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm&nbsp;index.jsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u76d1\u542c80\u7aef\u53e3\uff0c\u8bbf\u95ee\u57df\u540d\u4e3awww.123.com\uff0c\u4e0d\u52a0\u7aef\u53e3\u53f7\u65f6\u9ed8\u8ba4\u4e3a80\u7aef\u53e3\uff0c\u6545\u8bbf\u95ee\u8be5\u57df\u540d\u65f6\u4f1a\u8df3\u8f6c\u5230127.0.0.1:8080\u8def\u5f84\u4e0a\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u9650\u6d41\u914d\u7f6e<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u6f0f\u6876\u7b97\u6cd5\u4e0e\u4ee4\u724c\u6876\u7b97\u6cd5\u533a\u522b\uff1a\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u201c\u6f0f\u6876\u7b97\u6cd5\u201d\u80fd\u591f\u5f3a\u884c\u9650\u5236\u6570\u636e\u7684\u4f20\u8f93\u901f\u7387\uff0c<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u800c\u201c\u4ee4\u724c\u6876\u7b97\u6cd5\u201d\u5728\u80fd\u591f\u9650\u5236\u6570\u636e\u7684\u5e73\u5747\u4f20\u8f93\u901f\u7387\u5916\uff0c\u8fd8\u5141\u8bb8\u67d0\u79cd\u7a0b\u5ea6\u7684\u7a81\u53d1\u4f20\u8f93\u3002\u5728\u201c\u4ee4\u724c\u6876\u7b97\u6cd5\u201d\u4e2d\uff0c\u53ea\u8981\u4ee4\u724c\u6876\u4e2d\u5b58\u5728\u4ee4\u724c\uff0c\u90a3\u4e48\u5c31\u5141\u8bb8\u7a81\u53d1\u5730\u4f20\u8f93\u6570\u636e\u76f4\u5230\u8fbe\u5230\u7528\u6237\u914d\u7f6e\u7684\u95e8\u9650\uff0c\u56e0\u6b64\u5b83\u9002\u5408\u4e8e\u5177\u6709\u7a81\u53d1\u7279\u6027\u7684\u6d41\u91cf\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">Nginx\u6309\u8bf7\u6c42\u901f\u7387\u9650\u901f\u6a21\u5757\u4f7f\u7528\u7684\u662f\u6f0f\u6876\u7b97\u6cd5\uff0c\u5373\u80fd\u591f\u5f3a\u884c\u4fdd\u8bc1\u8bf7\u6c42\u7684\u5b9e\u65f6\u5904\u7406\u901f\u5ea6\u4e0d\u4f1a\u8d85\u8fc7\u8bbe\u7f6e\u7684\u9608\u503c\u3002<\/span><\/p>\n<ul>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">limit_req_zone \u7528\u6765\u9650\u5236\u5355\u4f4d\u65f6\u95f4\u5185\u7684\u8bf7\u6c42\u6570\uff0c\u5373\u901f\u7387\u9650\u5236,\u91c7\u7528\u7684\u6f0f\u6876\u7b97\u6cd5 &#8220;leaky bucket&#8221;\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">limit_req_conn \u7528\u6765\u9650\u5236\u540c\u4e00\u65f6\u95f4\u8fde\u63a5\u6570\uff0c\u5373\u5e76\u53d1\u9650\u5236\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">limit_req_zone \u53c2\u6570\u914d\u7f6e<\/span><\/p>\n<pre>Syntax:&nbsp;&nbsp;&nbsp;&nbsp;limit_req&nbsp;zone=name&nbsp;[burst=number]&nbsp;[nodelay];\nDefault:&nbsp;&nbsp;&nbsp;&nbsp;\u2014\nContext:&nbsp;&nbsp;&nbsp;&nbsp;http,&nbsp;server,&nbsp;location<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">limit_req_zone $binary_remote_addr zone=one:10m rate=1r\/s;<\/span><\/p>\n<ul>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u7b2c\u4e00\u4e2a\u53c2\u6570\uff1a<\/span><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">$binary_remote_addr<\/span><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u8868\u793a\u901a\u8fc7remote_addr\u8fd9\u4e2a\u6807\u8bc6\u6765\u505a\u9650\u5236\uff0c\u201cbinary_\u201d\u7684\u76ee\u7684\u662f\u7f29\u5199\u5185\u5b58\u5360\u7528\u91cf\uff0c\u662f\u9650\u5236\u540c\u4e00\u5ba2\u6237\u7aefip\u5730\u5740\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff1azone=one:10m\u8868\u793a\u751f\u6210\u4e00\u4e2a\u5927\u5c0f\u4e3a10M\uff0c\u540d\u5b57\u4e3aone\u7684\u5185\u5b58\u533a\u57df\uff0c\u7528\u6765\u5b58\u50a8\u8bbf\u95ee\u7684\u9891\u6b21\u4fe1\u606f\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\u7b2c\u4e09\u4e2a\u53c2\u6570\uff1arate=1r\/s\u8868\u793a\u5141\u8bb8\u76f8\u540c\u6807\u8bc6\u7684\u5ba2\u6237\u7aef\u7684\u8bbf\u95ee\u9891\u6b21\uff0c\u8fd9\u91cc\u9650\u5236\u7684\u662f\u6bcf\u79d21\u6b21\uff0c\u8fd8\u53ef\u4ee5\u6709\u6bd4\u598230r\/m\u7684\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">limit_req zone=one burst=5 nodelay;<\/span><\/p>\n<ul>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\u7b2c\u4e00\u4e2a\u53c2\u6570\uff1azone=one \u8bbe\u7f6e\u4f7f\u7528\u54ea\u4e2a\u914d\u7f6e\u533a\u57df\u6765\u505a\u9650\u5236\uff0c\u4e0e\u4e0a\u9762limit_req_zone \u91cc\u7684name\u5bf9\u5e94\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff1aburst=5\uff0c\u91cd\u70b9\u8bf4\u660e\u4e00\u4e0b\u8fd9\u4e2a\u914d\u7f6e\uff0cburst\u7206\u53d1\u7684\u610f\u601d\uff0c\u8fd9\u4e2a\u914d\u7f6e\u7684\u610f\u601d\u662f\u8bbe\u7f6e\u4e00\u4e2a\u5927\u5c0f\u4e3a5\u7684\u7f13\u51b2\u533a\u5f53\u6709\u5927\u91cf\u8bf7\u6c42\uff08\u7206\u53d1\uff09\u8fc7\u6765\u65f6\uff0c\u8d85\u8fc7\u4e86\u8bbf\u95ee\u9891\u6b21\u9650\u5236\u7684\u8bf7\u6c42\u53ef\u4ee5\u5148\u653e\u5230\u8fd9\u4e2a\u7f13\u51b2\u533a\u5185\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\u7b2c\u4e09\u4e2a\u53c2\u6570\uff1anodelay\uff0c\u5982\u679c\u8bbe\u7f6e\uff0c\u8d85\u8fc7\u8bbf\u95ee\u9891\u6b21\u800c\u4e14\u7f13\u51b2\u533a\u4e5f\u6ee1\u4e86\u7684\u65f6\u5019\u5c31\u4f1a\u76f4\u63a5\u8fd4\u56de503\uff0c\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\uff0c\u5219\u6240\u6709\u8bf7\u6c42\u4f1a\u7b49\u5f85\u6392\u961f\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">ngx_http_limit_conn_module \u53c2\u6570\u914d\u7f6e<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u8fd9\u4e2a\u6a21\u5757\u7528\u6765\u9650\u5236\u5355\u4e2aIP\u7684\u8bf7\u6c42\u6570\u3002\u5e76\u975e\u6240\u6709\u7684\u8fde\u63a5\u90fd\u88ab\u8ba1\u6570\u3002\u53ea\u6709\u5728\u670d\u52a1\u5668\u5904\u7406\u4e86\u8bf7\u6c42\u5e76\u4e14\u5df2\u7ecf\u8bfb\u53d6\u4e86\u6574\u4e2a\u8bf7\u6c42\u5934\u65f6\uff0c\u8fde\u63a5\u624d\u88ab\u8ba1\u6570\u3002<\/span><\/p>\n<pre>Syntax:&nbsp;&nbsp;&nbsp;&nbsp;limit_conn&nbsp;zone&nbsp;number;\nDefault:&nbsp;&nbsp;&nbsp;&nbsp;\u2014\nContext:&nbsp;&nbsp;&nbsp;&nbsp;http,&nbsp;server,&nbsp;location\n\nlimit_conn_zone&nbsp;$binary_remote_addr&nbsp;zone=addr:10m;\nserver&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/download\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;limit_conn&nbsp;addr&nbsp;1;\n&nbsp;&nbsp;&nbsp;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u4e00\u6b21\u53ea\u5141\u8bb8\u6bcf\u4e2aIP\u5730\u5740\u4e00\u4e2a\u8fde\u63a5\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u8d1f\u8f7d\u5747\u8861<\/span><\/p>\n<pre>#user&nbsp;&nbsp;nobody;\nworker_processes&nbsp;&nbsp;1;\nerror_log&nbsp;&nbsp;logs\/error.log;#&nbsp;\u5f00\u542f\u65e5\u5fd7\npid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logs\/nginx.pid;\n...\n&nbsp;&nbsp;&nbsp;&nbsp;upstream&nbsp;lyf&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;192.168.37.220:8001;&nbsp;#&nbsp;3\u4e2atomcat\u670d\u52a1\n&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;192.168.37.220:8002;\n&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;192.168.37.220:8003;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;192.168.37.220;#&nbsp;\u76d1\u542cip\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;&nbsp;&nbsp;http:\/\/lyf;&nbsp;&nbsp;#&nbsp;\u8bbe\u7f6e\u4ee3\u7406\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">keepalive \u957f\u8fde\u63a5\u63d0\u9ad8\u541e\u5410\u91cf<br \/>keepalived \uff1a\u8bbe\u7f6e\u957f\u8fde\u63a5\u5904\u7406\u7684\u6570\u91cf<br \/>proxy_http_version \uff1a\u8bbe\u7f6e\u957f\u8fde\u63a5http\u7248\u672c\u4e3a1.1<br \/>proxy_set_header \uff1a\u6e05\u9664connection header \u4fe1\u606f<\/span><\/p>\n<pre>upstream&nbsp;tomcats&nbsp;{&nbsp;\n#&nbsp;server&nbsp;192.168.1.173:8080&nbsp;max_fails=2&nbsp;fail_timeout=1s;&nbsp;\nserver&nbsp;192.168.1.190:8080;&nbsp;\n#&nbsp;server&nbsp;192.168.1.174:8080&nbsp;weight=1;&nbsp;\n#&nbsp;server&nbsp;192.168.1.175:8080&nbsp;weight=1;&nbsp;\nkeepalive&nbsp;32;&nbsp;\n}\nserver&nbsp;{\nlisten&nbsp;80;&nbsp;\nserver_name&nbsp;www.tomcats.com;&nbsp;\nlocation&nbsp;\/&nbsp;{&nbsp;\nproxy_pass&nbsp;http:\/\/tomcats;&nbsp;\nproxy_http_version&nbsp;1.1;&nbsp;\nproxy_set_header&nbsp;Connection&nbsp;\"\";&nbsp;\n}&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u5de5\u4f5c\u65b9\u5f0f<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u8f6e\u8be2\u65b9\u5f0f\u662fNginx\u8d1f\u8f7d\u9ed8\u8ba4\u7684\u65b9\u5f0f<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u6743\u91cd\u65b9\u5f0f \u6307\u5b9a\u6bcf\u4e2a\u670d\u52a1\u7684\u6743\u91cd\u6bd4\u4f8b\uff0cweight\u548c\u8bbf\u95ee\u6bd4\u7387\u6210\u6b63\u6bd4<\/span><\/p>\n<pre>upstream&nbsp;&nbsp;dalaoyang-server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;&nbsp;&nbsp;&nbsp;localhost:10001&nbsp;weight=1;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;&nbsp;&nbsp;&nbsp;localhost:10002&nbsp;weight=2;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">iphash<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u6bcf\u4e2a\u8bf7\u6c42\u90fd\u6839\u636e\u8bbf\u95eeip\u7684hash\u7ed3\u679c\u5206\u914d\uff0c\u7ecf\u8fc7\u8fd9\u6837\u7684\u5904\u7406\uff0c\u6bcf\u4e2a\u8bbf\u5ba2\u56fa\u5b9a\u8bbf\u95ee\u4e00\u4e2a\u540e\u7aef\u670d\u52a1\uff0c\u5982\u4e0b\u914d\u7f6e\uff08ip_hash\u53ef\u4ee5\u548cweight\u914d\u5408\u4f7f\u7528\uff09\u3002<\/span><\/p>\n<pre>upstream&nbsp;&nbsp;dalaoyang-server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ip_hash;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;&nbsp;&nbsp;&nbsp;localhost:10001&nbsp;weight=1;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;&nbsp;&nbsp;&nbsp;localhost:10002&nbsp;weight=2;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u6700\u5c11\u8fde\u63a5<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u5c06\u8bf7\u6c42\u5206\u914d\u5230\u8fde\u63a5\u6570\u6700\u5c11\u7684\u670d\u52a1\u4e0a\u3002<\/span><\/p>\n<pre>upstream&nbsp;&nbsp;dalaoyang-server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;least_conn;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;&nbsp;&nbsp;&nbsp;localhost:10001&nbsp;weight=1;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;&nbsp;&nbsp;&nbsp;localhost:10002&nbsp;weight=2;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">fair<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u6309\u540e\u7aef\u670d\u52a1\u5668\u7684\u54cd\u5e94\u65f6\u95f4\u6765\u5206\u914d\u8bf7\u6c42\uff0c\u54cd\u5e94\u65f6\u95f4\u77ed\u7684\u4f18\u5148\u5206\u914d\u3002<\/span><\/p>\n<pre>upstream&nbsp;&nbsp;dalaoyang-server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;&nbsp;&nbsp;&nbsp;localhost:10001&nbsp;weight=1;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;&nbsp;&nbsp;&nbsp;localhost:10002&nbsp;weight=2;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fair;&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">Consul+upsync+Nginx &nbsp;\u5b9e\u73b0\u65e0\u9700raload\u52a8\u6001\u8d1f\u8f7d\u5747\u8861 https:\/\/www.cnblogs.com\/a1304908180\/p\/10697278.html<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u4f20\u7edf\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u5982\u679cUpstream\u53c2\u6570\u53d1\u751f\u53d8\u5316\uff0c\u6bcf\u6b21\u90fd\u9700\u8981\u91cd\u65b0\u52a0\u8f7dnginx.conf\u6587\u4ef6,<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u56e0\u6b64\u6269\u5c55\u6027\u4e0d\u662f\u5f88\u9ad8\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u91c7\u7528\u52a8\u6001\u8d1f\u8f7d\u5747\u8861\uff0c\u5b9e\u73b0Upstream\u53ef\u914d\u7f6e\u5316\u3001\u52a8\u6001\u5316\uff0c\u65e0\u9700\u4eba\u5de5\u91cd\u65b0\u52a0\u8f7dnginx.conf\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">LVS+Keepalived+Nginx+Tomcat\u642d\u5efa\u9ad8\u53ef\u7528\u53cc\u673a\u4e3b\u4ece\u70ed\u5907\u96c6\u7fa4<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">https:\/\/blog.csdn.net\/dsen726\/article\/details\/89519013<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u9700\u8981\u660e\u786e\u7684\u662f\uff1a<\/span><\/p>\n<ul>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">Nginx\u4e24\u53f0\u662f\u4e3b\u5907\u5173\u7cfb\uff0c\u53ea\u6709\u4e00\u53f0\u5728\u5de5\u4f5c\u3002\u540e\u9762\u7684tomcat\u662f\u96c6\u7fa4\uff0c\u540c\u65f6\u5de5\u4f5c\u7684\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">keepalived\u662f\u540c\u65f6\u5b89\u88c5\u5728\u4e24\u53f0Nginx\u4e0a\u7684\uff0c\u4e0d\u8fc7\u6587\u4ef6\u914d\u7f6e\u4e0d\u4e00\u6837<\/span><\/p>\n<\/li>\n<li>\n<p style=\"margin: 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;color: inherit;line-height: inherit;font-size: 15px\">\u8fd9\u91cc\u7684\u53cc\u673a\u70ed\u5907\u662f\u6307LVS\uff0cNginx\u5219\u662f\u96c6\u7fa4<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">keepalived<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u5065\u5eb7\u68c0\u67e5\u548c\u5931\u8d25\u5207\u6362\u662fkeepalived\u7684\u4e24\u5927\u6838\u5fc3\u529f\u80fd\u3002\u6240\u8c13\u7684\u5065\u5eb7\u68c0\u67e5\uff0c\u5c31\u662f\u91c7\u7528tcp\u4e09\u6b21\u63e1\u624b\uff0cicmp\u8bf7\u6c42\uff0chttp\u8bf7\u6c42\uff0cudp echo\u8bf7\u6c42\u7b49\u65b9\u5f0f\u5bf9\u8d1f\u8f7d\u5747\u8861\u5668\u540e\u9762\u7684\u5b9e\u9645\u7684\u670d\u52a1\u5668(\u901a\u5e38\u662f\u627f\u8f7d\u771f\u5b9e\u4e1a\u52a1\u7684\u670d\u52a1\u5668)\u8fdb\u884c\u4fdd\u6d3b\uff1b\u800c\u5931\u8d25\u5207\u6362\u4e3b\u8981\u662f\u5e94\u7528\u4e8e\u914d\u7f6e\u4e86\u4e3b\u5907\u6a21\u5f0f\u7684\u8d1f\u8f7d\u5747\u8861\u5668\uff0c\u5229\u7528VRRP\u7ef4\u6301\u4e3b\u5907\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u5fc3\u8df3\uff0c\u5f53\u4e3b\u8d1f\u8f7d\u5747\u8861\u5668\u51fa\u73b0\u95ee\u9898\u65f6\uff0c\u7531\u5907\u8d1f\u8f7d\u5747\u8861\u5668\u627f\u8f7d\u5bf9\u5e94\u7684\u4e1a\u52a1\uff0c\u4ece\u800c\u5728\u6700\u5927\u9650\u5ea6\u4e0a\u51cf\u5c11\u6d41\u91cf\u635f\u5931\uff0c\u5e76\u63d0\u4f9b\u670d\u52a1\u7684\u7a33\u5b9a\u6027\u3002\u53e6\u5916\uff0c\u641c\u7d22\u516c\u4f17\u53f7Linux\u5c31\u8be5\u8fd9\u6837\u5b66\u540e\u53f0\u56de\u590d\u201c\u7334\u5b50\u201d\uff0c\u83b7\u53d6\u4e00\u4efd\u60ca\u559c\u793c\u5305\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">LVS\u662fLinux Virtual Server\u7684\u7b80\u5199\uff0c\u610f\u5373Linux\u865a\u62df\u670d\u52a1\u5668\uff0c\u662f\u4e00\u4e2a\u865a\u62df\u7684\u670d\u52a1\u5668\u96c6\u7fa4\u7cfb\u7edf\u3002lvs\u76ee\u524d\u662f\u96c6\u6210\u5728Linux\u5185\u7684\u3002<\/span><\/p>\n<p style=\"margin: 0px 0px 0em;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/e1224a7ab7506c8c022699d0899e1f71-2.png\" class=\"aligncenter\" title=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe2\" alt=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe2\" \/><\/p>\n<p style=\"margin: 0px 0px 0em;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/e1224a7ab7506c8c022699d0899e1f71-3.png\" class=\"aligncenter\" title=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe3\" alt=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe3\" \/><\/p>\n<p style=\"margin: 0px 0px 0em;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-family: system-ui, -apple-system, BlinkMacSystemFont,\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/eb28d6a79f2638d6a8acc99a448bd476-4.png\" class=\"aligncenter\" title=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe4\" alt=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe4\" \/><\/p>\n<h4><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: inherit;color: inherit;line-height: inherit\">\u4e3a\u4ec0\u4e48\u8981LVS+Nginx\uff1f<\/span><\/h4>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u4e00\u3001ngix\uff08\u5e94\u7528\u5c42 \u7f51\u7edc\u4e03\u5c42\u8d1f\u8f7d\u5747\u8861\uff09<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">1\u3001\u5f02\u6b65\u8f6c\u53d1\uff0c\u8bf7\u6c42\u6570\u636e\u548c\u76f8\u5e94\u6570\u636e\u90fd\u8981\u7ecf\u8fc7ngix\uff0cngix\u548c\u5ba2\u6237\u7aef\u5efa\u7acb\u8fde\u63a5<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">2\u3001\u8f6e\u8be2\u6240\u6709\u7684tomcat\u670d\u52a1\u5668\uff0c\u4fdd\u8bc1\u8bf7\u6c42\u6210\u529f\u6216\u8005\u6700\u540e\u4e00\u53f0tomcat\u670d\u52a1\u5668\u4e5f\u8bf7\u6c42\u5931\u8d25<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">\u4e8c\u3001lvs(\u7f51\u7edc\u5c42 &nbsp;\u7f51\u7edc\u56db\u5c42\u8d1f\u8f7d\u5747\u8861)<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">1\u3001\u540c\u6b65\u8f6c\u53d1\u63a5\u53d7\u8bf7\u6c42\u6570\u636e\uff0clvs\u8f6c\u53d1\u5230\u670d\u52a1\u5668\uff0c\u670d\u52a1\u5668\u76f4\u63a5\u548c\u5ba2\u6237\u7aef\u5efa\u7acb\u8fde\u63a5<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">nginx\u8981\u627f\u53d7\u6240\u6709\u7684\u6d41\u91cf\uff0c\u5f53\u4e00\u53f0nigx\u627f\u53d7\u4e0d\u4e86\uff0c\u5c31\u9700\u8981\u642d\u5efangix\u96c6\u7fa4\u3002ngix+ngix \u5916\u5c42\u7684ngix\u8fd8\u662f\u8981\u627f\u53d7\u6240\u6709\u6d41\u91cf\u3002<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><span style=\"margin: 0px;padding: 0px;max-width: 100%;font-size: 15px\">lvs+ngix:lvs\u540c\u6b65\u8f6c\u53d1\u4e0d\u4f1a\u63a5\u53d7\u76f8\u5e94\u6570\u636e\uff0cLVS\u91c7\u7528DR\u6a21\u5f0f\u65f6\u4e0d\u7528\u54cd\u5e94\u670d\u52a1\u5668\u8fd4\u56de\u7684\u5185\u5bb9\u3002\uff08\u901a\u5e38\u8bf7\u6c42\u6570\u636e\u662f\u6bd4\u8f83\u5c0f\u7684\uff0c\u54cd\u5e94\u6570\u636e\u4f1a\u6bd4\u8f83\u5927\uff09<\/span><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/eb28d6a79f2638d6a8acc99a448bd476-5.png\" class=\"aligncenter\" title=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe5\" alt=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe5\" \/><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u9759\u6001\u8d44\u6e90\u914d\u7f6e<\/p>\n<pre>&nbsp;&nbsp;location&nbsp;~&nbsp;.*.(jpg|gif|png)$&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip&nbsp;on;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip_http_version&nbsp;1.1;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip_comp_level&nbsp;2;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip_types&nbsp;text\/plain&nbsp;application\/javascript&nbsp;image\/jpeg&nbsp;image\/gif&nbsp;image\/png;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;\/usr\/share\/nginx\/images;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;~&nbsp;.*.(txt|xml)$&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip&nbsp;on;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip_http_version&nbsp;1.1;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip_comp_level&nbsp;1;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip_types&nbsp;text\/plain&nbsp;application\/javascript&nbsp;image\/jpeg&nbsp;image\/gif&nbsp;image\/png;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;\/usr\/share\/nginx\/code;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;location&nbsp;~&nbsp;^\/download&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip_static&nbsp;on;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tcp_nopush&nbsp;on;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;\/opt\/app\/code;\n&nbsp;&nbsp;&nbsp;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">sendfile on | off\uff0c\u6587\u4ef6\u8bfb\u53d6\u914d\u7f6e<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u9ed8\u8ba4sendfile\u662f\u5173\u95ed\u7684\uff0c\u53ef\u4ee5\u914d\u7f6e\u5728http,server,location,if in location\u4e2d<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">tcp_nopush on | off,\u591a\u4e2a\u5305\u6574\u5408<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u9ed8\u8ba4\u662f\u5173\u95ed\u72b6\u6001\uff0c\u53ef\u4ee5\u5728http,server,location\u4e2d\u914d\u7f6e\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u5728sendfile\u5f00\u542f\u7684\u60c5\u51b5\u4e0b\uff0c\u63d0\u9ad8\u7f51\u7edc\u5305\u7684\u4f20\u8f93\u6548\u7387\u3002\u4ec0\u4e48\u610f\u601d\u5462\uff0c\u5047\u8bbe\u670d\u52a1\u7aef\u6536\u5230\u8bf7\u6c42\uff0c\u9700\u8981\u63a8\u900110\u4e2a\u5305\uff0c\u4e3a\u4e86\u63d0\u9ad8\u4f20\u8f93\u6548\u7387\uff0c\u8fd910\u4e2a\u5305\u4e0d\u4f1a\u4e00\u4e2a\u4e00\u4e2a\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0c\u800c\u662f\u5c0610\u4e2a\u5305\u6512\u591f\u4e86\u540e\u4e00\u8d77\u8fd4\u56de\u56de\u53bb\u3002<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">tcp_nodelay on | off,\u7f51\u7edc\u5305\u7684\u5b9e\u65f6\u6027\u4f20\u8f93<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u9ed8\u8ba4\u5f00\u542f\uff0c\u53ef\u4ee5\u5728http,server,location\u4e2d\u914d\u7f6e\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u5728keepalive\u94fe\u63a5\u4e0b\uff0c\u63d0\u9ad8\u7f51\u7edc\u5305\u7684\u4f20\u8f93\u5b9e\u65f6\u6027\u3002<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">gzip on | off\uff0c\u538b\u7f29<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u9ed8\u8ba4\u662f\u5173\u95ed\u72b6\u6001\uff0c\u53ef\u4ee5\u5728http,server,location,if in location\u4e2d\u914d\u7f6e\uff0c\u4f5c\u7528\u662f\u538b\u7f29\u4f20\u8f93\u3002\u4e00\u822c\u6765\u8bf4\u6d4f\u89c8\u5668\u662f\u53ef\u4ee5\u5bf9\u538b\u7f29\u540e\u7684\u5185\u5bb9\u8fdb\u884c\u89e3\u538b\u7684\u3002<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">gzip_comp_level level;\u538b\u7f29\u7ea7\u522b<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u9ed8\u8ba4\u7684\u538b\u7f29\u7ea7\u522b\u662f1\uff0c\u53ef\u4ee5\u5728http,server,location\u4e2d\u914d\u7f6e\uff0c\u7ea7\u522b\u914d\u7f6e\u7684\u8d8a\u9ad8\uff0c\u538b\u7f29\u7684\u8d8a\u597d\uff0c\u4f46\u662f\u538b\u7f29\u4f1a\u8017\u8d39\u670d\u52a1\u7aef\u7684\u8ba1\u7b97\u8d44\u6e90\uff0c\u6240\u4ee5\u8981\u63a7\u5236\u597d\u538b\u7f29\u7ea7\u522b<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">gzip_http_version 1.0 | 1.1\uff0c\u538b\u7f29\u5bf9http\u534f\u8bae\u7684\u652f\u6301<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u9ed8\u8ba4\u5bf9HTTP\/1.1\u534f\u8bae\u7684\u8bf7\u6c42\u624d\u4f1a\u8fdb\u884cgzip\u538b\u7f29,\u53ef\u4ee5\u914d\u7f6e\u5728http,server,location\u4e2d\u914d\u7f6e\u3002\u5f53\u7528\u6237\u60f3\u8981\u8bfb\u53d6\u4e00\u4e2a1.html\u6587\u4ef6\uff0c\u9996\u5148\u4f1a\u5728\u76ee\u5f55\u4e2d\u627e\u5bfb1.html.gz\u662f\u5426\u5b58\u5728\uff0c\u6240\u4ee5\u8fd9\u5c31\u5bfc\u81f4\u4e86\u78c1\u76d8\u8d44\u6e90\u7684\u6d6a\u8d39\uff0c\u5fc5\u987b\u8981\u5b58\u50a8\u4e24\u4efd\u6587\u4ef6\u3002<\/p>\n<pre>###\u9759\u6001\u8d44\u6e90\u8bbf\u95ee\n&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;static.itmayiedu.com;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/static\/imgs&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;F:\/;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;###\u52a8\u6001\u8d44\u6e90\u8bbf\u95ee\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;www.itmayiedu.com;\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8080;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u8de8\u57df\u914d\u7f6e<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/e93a985d7a5332b563da728150f6aea2-6.png\" class=\"aligncenter\" title=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe6\" alt=\"\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u63d2\u56fe6\" \/><\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u8de8\u57df\u5c31\u662f\u5728\u539f\u7ad9\u70b9\u8bbf\u95ee\u57df\u540d\u4e0d\u540c\u7684\u5176\u4ed6\u7ad9\u70b9\uff0c\u540c\u6e90\u7b56\u7565\u4f1a\u963b\u6b62\u4e00\u4e2a\u57df\u7684javascript\u811a\u672c\u548c\u53e6\u5916\u4e00\u4e2a\u57df\u7684\u5185\u5bb9\u8fdb\u884c\u4ea4\u4e92\u3002\u6240\u8c13\u540c\u6e90\uff08\u5373\u6307\u5728\u540c\u4e00\u4e2a\u57df\uff09\u5c31\u662f\u4e24\u4e2a\u9875\u9762\u5177\u6709\u76f8\u540c\u7684\u534f\u8bae\uff08protocol\uff09\uff0c\u4e3b\u673a\uff08host\uff09\u548c\u7aef\u53e3\u53f7\uff08port\uff09\u3002<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">CORS \u662f\u8de8\u57df\u8d44\u6e90\u5206\u4eab\uff08Cross-Origin Resource Sharing\uff09\u7684\u7f29\u5199\u3002\u5b83\u662f W3C \u6807\u51c6\uff0c\u5c5e\u4e8e\u8de8\u6e90 AJAX \u8bf7\u6c42\u7684\u6839\u672c\u89e3\u51b3\u65b9\u6cd5\u3002<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">1\u3001\u666e\u901a\u8de8\u57df\u8bf7\u6c42\uff1a\u53ea\u9700\u670d\u52a1\u5668\u7aef\u8bbe\u7f6eAccess-Control-Allow-Origin<\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">2\u3001\u5e26cookie\u8de8\u57df\u8bf7\u6c42\uff1a\u524d\u540e\u7aef\u90fd\u9700\u8981\u8fdb\u884c\u8bbe\u7f6e<\/p>\n<pre>#\u5141\u8bb8\u8de8\u57df\u8bf7\u6c42\u7684\u57df\uff0c*\u4ee3\u8868\u6240\u6709\nadd_header&nbsp;'Access-Control-Allow-Origin'&nbsp;*;\n#\u5141\u8bb8\u5e26\u4e0acookie\u8bf7\u6c42&nbsp;\nadd_header&nbsp;'Access-Control-Allow-Credentials'&nbsp;'true';&nbsp;\n#\u5141\u8bb8\u8bf7\u6c42\u7684\u65b9\u6cd5\uff0c\u6bd4\u5982&nbsp;GET\/POST\/PUT\/DELETE&nbsp;\nadd_header&nbsp;'Access-Control-Allow-Methods'&nbsp;*;&nbsp;\n#\u5141\u8bb8\u8bf7\u6c42\u7684header&nbsp;\nadd_header&nbsp;'Access-Control-Allow-Headers'&nbsp;*;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">\u9632\u76d7\u94fe<\/p>\n<pre>#\u5bf9\u6e90\u7ad9\u70b9\u9a8c\u8bc1\nvalid_referers&nbsp;*.imooc.com;&nbsp;\n#\u975e\u6cd5\u5f15\u5165\u4f1a\u8fdb\u5165\u4e0b\u65b9\u5224\u65ad&nbsp;\nif&nbsp;($invalid_referer)&nbsp;{&nbsp;return&nbsp;404;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"margin: 1.5em 0px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;font-size: inherit;color: inherit;line-height: inherit\">source: https:\/\/www.yuque.com\/molizhuzhu\/thrgrk\/rtslmc<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e00\u5f20\u5c0f\u56fe\u770b\u5c3d Nginx\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5 Nginx\u5b89\u88c5\u5b8c\u6210\uff0c\u6ca1\u6709sbin\u76ee\u5f55 cd\u8fdb\u5165\u5230nginx-1.18.0\u76ee\u5f55\u5185\u6267\u884c [root@centos7&nbsp;nginx-1.18.0]#&nbsp;.\/configure&nbsp;&#8211;prefix=\/usr\/local\/nginx[root@centos7&nbsp;nginx-1.18.0]#&nbsp;make[root@centos7&nbsp;nginx-1.18.0]#&nbsp;make&nbsp;install \u767b\u5f55\u540e\u590d\u5236 ps\uff1a\u2013prefix=path \u5b9a\u4e49\u4e00\u4e2a\u76ee\u5f55\uff0c\u5b58\u653e\u670d\u52a1\u5668\u4e0a\u7684\u6587\u4ef6 \uff0c\u4e5f\u5c31\u662fnginx\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u9ed8\u8ba4\u4f7f\u7528 \/usr\/local\/nginx \u8fd9\u6b65\u4f60\u4f1a\u770b\u5230local\u76ee\u5f55\u4e0b\u6709\u4e00\u4e2a\u8ddf\u4f60\u5b89\u88c5\u7684nginx1.12.2\u540c\u7ea7\u7684nginx\u76ee\u5f55\uff0c\u91cc\u9762\u5c31\u6709sbin\u76ee\u5f55\u4e86\u3002 \u57fa\u7840\u6307\u4ee4 listen\uff1a\u8be5\u6307\u4ee4\u7528\u4e8e\u914d\u7f6e\u7f51\u7edc\u76d1\u542c\u3002 listen&nbsp;*:80&nbsp;|&nbsp;*:8080&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u76d1\u542c\u6240\u670980\u7aef\u53e3\u548c8080\u7aef\u53e3listen&nbsp;&nbsp;IP_address:port&nbsp;&nbsp;&nbsp;#\u76d1\u542c\u6307\u5b9a\u7684\u5730\u5740\u548c\u7aef\u53e3\u53f7listen&nbsp;&nbsp;IP_address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u76d1\u542c\u6307\u5b9aip\u5730\u5740\u6240\u6709\u7aef\u53e3listen&nbsp;port&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u76d1\u542c\u8be5\u7aef\u53e3\u7684\u6240\u6709IP\u8fde\u63a5 \u767b\u5f55\u540e\u590d\u5236 server_name\uff1a\u8be5\u6307\u4ee4\u7528\u4e8e\u865a\u62df\u4e3b\u673a\u7684\u914d\u7f6e\u3002 a. \u57fa\u4e8e\u540d\u79f0\u7684\u865a\u62df\u4e3b\u673a\u914d\u7f6e server_name&nbsp;&nbsp;&nbsp;name&nbsp;&#8230;; \u767b\u5f55\u540e\u590d\u5236 b. \u57fa\u4e8e IP \u5730\u5740\u7684\u865a\u62df\u4e3b\u673a\u914d\u7f6e server_name&nbsp;192.168.1.1 \u767b\u5f55\u540e\u590d\u5236 location\uff1a\u8be5\u6307\u4ee4\u7528\u4e8e\u5339\u914d URL\u3002 location\u6307\u4ee4\u7684\u4f5c\u7528\u662f\u6839\u636e\u7528\u6237\u8bf7\u6c42\u7684URI\u6765\u6267\u884c\u4e0d\u540c\u7684\u5e94\u7528\uff0c\u4e5f\u5c31\u662f\u6839\u636e\u7528\u6237\u8bf7\u6c42\u7684\u7f51\u7ad9URL\u8fdb\u884c\u5339\u914d\uff0c\u5339\u914d\u6210\u529f\u5373\u8fdb\u884c\u76f8\u5173\u7684\u64cd\u4f5c\u3002 \u725b\u903c\u554a\uff01\u63a5\u79c1\u6d3b\u5fc5\u5907\u7684&nbsp;N&nbsp;\u4e2a\u5f00\u6e90\u9879\u76ee\uff01\u8d76\u5feb\u6536\u85cf\u5427 \u767b\u5f55\u540e\u590d\u5236 location\u7684\u8bed\u6cd5 =\u5f00\u5934\u8868\u793a\u7cbe\u786e\u5339\u914d \u5982 A \u4e2d\u53ea\u5339\u914d\u6839\u76ee\u5f55\u7ed3\u5c3e\u7684\u8bf7\u6c42\uff0c\u540e\u9762\u4e0d\u80fd\u5e26\u4efb\u4f55\u5b57\u7b26\u4e32\u3002 ^~ \u5f00\u5934\u8868\u793auri\u4ee5\u67d0\u4e2a\u5e38\u89c4\u5b57\u7b26\u4e32\u5f00\u5934\uff0c\u4e0d\u662f\u6b63\u5219\u5339\u914d ~ \u5f00\u5934\u8868\u793a\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d; ~* \u5f00\u5934\u8868\u793a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d \/ \u901a\u7528\u5339\u914d, \u5982\u679c\u6ca1\u6709\u5176\u5b83\u5339\u914d,\u4efb\u4f55\u8bf7\u6c42\u90fd\u4f1a\u5339\u914d\u5230 Location\u6b63\u5219\u6848\u4f8b #\u7cbe\u786e\u5339\u914d,\/\u540e\u9762\u4e0d\u80fd\u5e26\u4efb\u4f55\u5b57\u7b26 server&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;80; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;www.itmayiedu.com; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u7cbe\u786e\u5339\u914d,\u6ce8\u89e3\u540e\u9762\u4e0d\u80fd\u5e26\u4efb\u4f55\u5b57\u7b26 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;=\/&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/127.0.0.1:8080; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} } [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-62088","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/62088","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=62088"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/62088\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=62088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=62088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=62088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}