{"id":62348,"date":"2025-04-29T13:49:58","date_gmt":"2025-04-29T05:49:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/62348\/"},"modified":"2025-04-29T13:49:58","modified_gmt":"2025-04-29T05:49:58","slug":"14%e4%b8%aanginx%e7%9a%84%e6%a0%b8%e5%bf%83%e5%8a%9f%e8%83%bd%e7%82%b9%ef%bc%8c%e5%bb%ba%e8%ae%ae%e6%94%b6%e8%97%8f%ef%bc%81-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/62348\/","title":{"rendered":"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01"},"content":{"rendered":"<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><span style=\"letter-spacing: 0px\">\u4eca\u5929\u6765\u548c\u5927\u5bb6\u804a\u804aNginx\u5728\u6211\u4eec\u5b9e\u9645\u5e94\u8fd0\u7528\u4e2d\u7684\u4e00\u4e9b\u975e\u5e38\u6709\u7528\u7684\u70b9\u3002<\/span><\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u65e9\u671f\u7684\u4e1a\u52a1\u90fd\u662f\u57fa\u4e8e\u5355\u4f53\u8282\u70b9\u90e8\u7f72\uff0c\u7531\u4e8e\u524d\u671f\u8bbf\u95ee\u6d41\u91cf\u4e0d\u5927\uff0c\u56e0\u6b64\u5355\u4f53\u7ed3\u6784\u4e5f\u53ef\u6ee1\u8db3\u9700\u6c42\uff0c\u4f46\u968f\u7740\u4e1a\u52a1\u589e\u957f\uff0c\u6d41\u91cf\u4e5f\u8d8a\u6765\u8d8a\u5927\uff0c\u90a3\u4e48\u6700\u7ec8\u5355\u53f0\u670d\u52a1\u5668\u53d7\u5230\u7684\u8bbf\u95ee\u538b\u529b\u4e5f\u4f1a\u9010\u6b65\u589e\u9ad8\u3002\u65f6\u95f4\u4e00\u957f\uff0c\u5355\u53f0\u670d\u52a1\u5668\u6027\u80fd\u65e0\u6cd5\u8ddf\u4e0a\u4e1a\u52a1\u589e\u957f\uff0c\u5c31\u4f1a\u9020\u6210\u7ebf\u4e0a\u9891\u7e41\u5b95\u673a\u7684\u73b0\u8c61\u53d1\u751f\uff0c\u6700\u7ec8\u5bfc\u81f4\u7cfb\u7edf\u762b\u75ea\u65e0\u6cd5\u7ee7\u7eed\u5904\u7406\u7528\u6237\u7684\u8bf7\u6c42\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4ece\u4e0a\u9762\u7684\u63cf\u8ff0\u4e2d\uff0c\u4e3b\u8981\u5b58\u5728\u4e24\u4e2a\u95ee\u9898\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2460\u5355\u4f53\u7ed3\u6784\u7684\u90e8\u7f72\u65b9\u5f0f\u65e0\u6cd5\u627f\u8f7d\u65e5\u76ca\u589e\u957f\u7684\u4e1a\u52a1\u6d41\u91cf\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2461\u5f53\u540e\u7aef\u8282\u70b9\u5b95\u673a\u540e\uff0c\u6574\u4e2a\u7cfb\u7edf\u4f1a\u9677\u5165\u762b\u75ea\uff0c\u5bfc\u81f4\u6574\u4e2a\u9879\u76ee\u4e0d\u53ef\u7528\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u56e0\u6b64\u5728\u8fd9\u79cd\u80cc\u666f\u4e0b\uff0c\u5f15\u5165\u8d1f\u8f7d\u5747\u8861\u6280\u672f\u53ef\u5e26\u6765\u7684\u6536\u76ca\uff1a<\/p>\n<ul>\n<li> <strong>\u300c\u7cfb\u7edf\u7684\u9ad8\u53ef\u7528\uff1a\u300d<\/strong> \u5f53\u67d0\u4e2a\u8282\u70b9\u5b95\u673a\u540e\u53ef\u4ee5\u8fc5\u901f\u5c06\u6d41\u91cf\u8f6c\u79fb\u81f3\u5176\u4ed6\u8282\u70b9\u3002 <\/li>\n<li> <strong>\u300c\u7cfb\u7edf\u7684\u9ad8\u6027\u80fd\uff1a\u300d<\/strong> \u591a\u53f0\u670d\u52a1\u5668\u5171\u540c\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\uff0c\u4e3a\u6574\u4e2a\u7cfb\u7edf\u63d0\u4f9b\u4e86\u66f4\u9ad8\u89c4\u6a21\u7684\u541e\u5410\u3002 <\/li>\n<li> <strong>\u300c\u7cfb\u7edf\u7684\u62d3\u5c55\u6027\uff1a\u300d<\/strong> \u5f53\u4e1a\u52a1\u518d\u6b21\u51fa\u73b0\u589e\u957f\u6216\u840e\u9761\u65f6\uff0c\u53ef\u518d\u52a0\u5165\/\u51cf\u5c11\u8282\u70b9\uff0c\u7075\u6d3b\u4f38\u7f29\u3002 <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">OK~\uff0c\u65e2\u7136\u5f15\u5165\u8d1f\u8f7d\u5747\u8861\u6280\u672f\u53ef\u7ed9\u6211\u4eec\u5e26\u6765\u5982\u6b64\u5de8\u5927\u7684\u597d\u5904\uff0c\u90a3\u4e48\u53c8\u6709\u90a3\u4e9b\u65b9\u6848\u53ef\u4f9b\u9009\u62e9\u5462\uff1f\u4e3b\u8981\u6709\u4e24\u79cd\u8d1f\u8f7d\u65b9\u6848\uff0c<strong>\u300c\u300c\u786c\u4ef6\u5c42\u9762\u4e0e\u8f6f\u4ef6\u5c42\u9762\u300d\u300d<\/strong> \uff0c\u6bd4\u8f83\u5e38\u7528\u7684\u786c\u4ef6\u8d1f\u8f7d\u5668\u6709A10\u3001F5\u7b49\uff0c\u4f46\u8fd9\u4e9b\u673a\u5668\u52a8\u8f84\u5927\u51e0\u4e07\u4e43\u81f3\u51e0\u5341\u4e07\u7684\u6210\u672c\uff0c\u56e0\u6b64\u4e00\u822c\u5927\u578b\u4f01\u4e1a\u4f1a\u91c7\u7528\u8be5\u65b9\u6848\uff0c\u5982\u94f6\u884c\u3001\u56fd\u4f01\u3001\u592e\u4f01\u7b49\u3002\u800c\u6210\u672c\u6709\u9650\uff0c\u4f46\u4f9d\u65e7\u60f3\u505a\u8d1f\u8f7d\u5747\u8861\u7684\u9879\u76ee\uff0c\u90a3\u4e48\u53ef\u5728\u8f6f\u4ef6\u5c42\u9762\u5b9e\u73b0\uff0c\u5982\u5178\u578b\u7684Nginx\u7b49\uff0c\u8f6f\u4ef6\u5c42\u7684\u8d1f\u8f7d\u4e5f\u662f\u672c\u6587\u7684\u91cd\u70b9\uff0c\u6bd5\u7adfBoss\u4eec\u7684\u51c6\u5219\u4e4b\u4e00\u5c31\u662f\uff1a<strong>\u300c\u300c\u80fd\u9760\u6280\u672f\u5b9e\u73b0\u7684\u5c31\u5c3d\u91cf\u4e0d\u82b1\u94b1\u3002\u300d\u300d<\/strong><\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>Java\u5f00\u53d1\u8005\u5728\u7ebf\u5237\u9898\u795e\u5668<\/strong><\/p>\n<h3> <span><\/span>\u4e00\u3001\u6027\u80fd\u602a\u517d-Nginx\u6982\u5ff5\u6df1\u5165\u6d45\u51fa<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">Nginx\u662f\u76ee\u524d\u8d1f\u8f7d\u5747\u8861\u6280\u672f\u4e2d\u7684\u4e3b\u6d41\u65b9\u6848\uff0c\u51e0\u4e4e\u7edd\u5927\u90e8\u5206\u9879\u76ee\u90fd\u4f1a\u4f7f\u7528\u5b83\uff0cNginx\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u9ad8\u6027\u80fdHTTP\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u540c\u65f6\u5b83\u4e5f\u662f\u4e00\u4e2a\u901a\u7528\u7c7b\u578b\u7684\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u652f\u6301\u7edd\u5927\u90e8\u5206\u534f\u8bae\uff0c\u5982TCP\u3001UDP\u3001SMTP\u3001HTTPS\u7b49\u3002<span style=\"letter-spacing: 0px\"><\/span><\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">Nginx\u4e0eRedis\u76f8\u540c\uff0c\u90fd\u662f\u57fa\u4e8e\u591a\u8def\u590d\u7528\u6a21\u578b\u6784\u5efa\u51fa\u7684\u4ea7\u7269\uff0c\u56e0\u6b64\u5b83\u4e0eRedis\u540c\u6837\u5177\u5907 <strong>\u300c\u300c\u8d44\u6e90\u5360\u7528\u5c11\u3001\u5e76\u53d1\u652f\u6301\u9ad8\u300d\u300d<\/strong> \u7684\u7279\u70b9\uff0c\u5728\u7406\u8bba\u4e0a\u5355\u8282\u70b9\u7684Nginx\u540c\u65f6\u652f\u63015W\u5e76\u53d1\u8fde\u63a5\uff0c\u800c\u5b9e\u9645\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u786c\u4ef6\u57fa\u7840\u5230\u4f4d\u518d\u7ed3\u5408\u7b80\u5355\u8c03\u4f18\u540e\u786e\u5b9e\u80fd\u8fbe\u5230\u8be5\u6570\u503c\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5148\u6765\u770b\u770bNginx\u5f15\u5165\u524d\u540e\uff0c\u5ba2\u6237\u7aef\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b\u7684\u5bf9\u6bd4\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/ff0a366f763830b671836876d22dc679-0.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe\" \/> <\/p>\n<p style=\"max-width:90%\">\u539f\u672c\u5ba2\u6237\u7aef\u662f\u76f4\u63a5\u8bf7\u6c42\u76ee\u6807\u670d\u52a1\u5668\uff0c\u7531\u76ee\u6807\u670d\u52a1\u5668\u76f4\u63a5\u5b8c\u6210\u8bf7\u6c42\u5904\u7406\u5de5\u4f5c\uff0c\u4f46\u52a0\u5165Nginx\u540e\uff0c\u6240\u6709\u7684\u8bf7\u6c42\u4f1a\u5148\u7ecf\u8fc7Nginx\uff0c\u518d\u7531\u5176\u8fdb\u884c\u5206\u53d1\u5230\u5177\u4f53\u7684\u670d\u52a1\u5668\u5904\u7406\uff0c\u5904\u7406\u5b8c\u6210\u540e\u518d\u8fd4\u56deNginx\uff0c\u6700\u540e\u7531Nginx\u5c06\u6700\u7ec8\u7684\u54cd\u5e94\u7ed3\u679c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4e86\u89e3\u4e86Nginx\u7684\u57fa\u672c\u6982\u5ff5\u540e\uff0c\u518d\u6765\u5feb\u901f\u642d\u5efa\u4e00\u4e0b\u73af\u5883\uff0c\u4ee5\u53ca\u4e86\u89e3\u4e00\u4e9bNginx\u7684\u9ad8\u7ea7\u7279\u6027\uff0c\u5982\u52a8\u9759\u5206\u79bb\u3001\u8d44\u6e90\u538b\u7f29\u3001\u7f13\u5b58\u914d\u7f6e\u3001IP\u9ed1\u540d\u5355\u3001\u9ad8\u53ef\u7528\u4fdd\u969c\u7b49\u3002<\/p>\n<h3> <span><\/span>\u4e8c\u3001Nginx\u73af\u5883\u642d\u5efa<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u9996\u5148\u521b\u5efaNginx\u7684\u76ee\u5f55\u5e76\u8fdb\u5165\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;mkdir&nbsp;\/soft&nbsp;&amp;amp;&amp;amp;&nbsp;mkdir&nbsp;\/soft\/nginx\/&nbsp;&nbsp;\n[root@localhost]#&nbsp;cd&nbsp;\/soft\/nginx\/<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4e0b\u8f7dNginx\u7684\u5b89\u88c5\u5305\uff0c\u53ef\u4ee5\u901a\u8fc7FTP\u5de5\u5177\u4e0a\u4f20\u79bb\u7ebf\u73af\u5883\u5305\uff0c\u4e5f\u53ef\u901a\u8fc7wget\u547d\u4ee4\u5728\u7ebf\u83b7\u53d6\u5b89\u88c5\u5305\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;wget&nbsp;https:\/\/nginx.org\/download\/nginx-1.21.6.tar.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6ca1\u6709wget\u547d\u4ee4\u7684\u53ef\u901a\u8fc7yum\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;yum&nbsp;-y&nbsp;install&nbsp;wget<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u89e3\u538bNginx\u7684\u538b\u7f29\u5305\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;tar&nbsp;-xvzf&nbsp;nginx-1.21.6.tar.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4e0b\u8f7d\u5e76\u5b89\u88c5Nginx\u6240\u9700\u7684\u4f9d\u8d56\u5e93\u548c\u5305\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;yum&nbsp;install&nbsp;--downloadonly&nbsp;--downloaddir=\/soft\/nginx\/&nbsp;gcc-c++&nbsp;&nbsp;\n[root@localhost]#&nbsp;yum&nbsp;install&nbsp;--downloadonly&nbsp;--downloaddir=\/soft\/nginx\/&nbsp;pcre&nbsp;pcre-devel4&nbsp;&nbsp;\n[root@localhost]#&nbsp;yum&nbsp;install&nbsp;--downloadonly&nbsp;--downloaddir=\/soft\/nginx\/&nbsp;zlib&nbsp;zlib-devel&nbsp;&nbsp;\n[root@localhost]#&nbsp;yum&nbsp;install&nbsp;--downloadonly&nbsp;--downloaddir=\/soft\/nginx\/&nbsp;openssl&nbsp;openssl-devel<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4e5f\u53ef\u4ee5\u901a\u8fc7yum\u547d\u4ee4\u4e00\u952e\u4e0b\u8f7d\uff08\u63a8\u8350\u4e0a\u9762\u54ea\u79cd\u65b9\u5f0f\uff09\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;yum&nbsp;-y&nbsp;install&nbsp;gcc&nbsp;zlib&nbsp;zlib-devel&nbsp;pcre-devel&nbsp;openssl&nbsp;openssl-devel<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6267\u884c\u5b8c\u6210\u540e\uff0c\u7136\u540els\u67e5\u770b\u76ee\u5f55\u6587\u4ef6\uff0c\u4f1a\u770b\u4e00\u5927\u5806\u4f9d\u8d56\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/ff0a366f763830b671836876d22dc679-1.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe1\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe1\" \/> <\/p>\n<p style=\"max-width:90%\">\u7d27\u63a5\u7740\u901a\u8fc7rpm\u547d\u4ee4\u4f9d\u6b21\u5c06\u4f9d\u8d56\u5305\u4e00\u4e2a\u4e2a\u6784\u5efa\uff0c\u6216\u8005\u901a\u8fc7\u5982\u4e0b\u6307\u4ee4\u4e00\u952e\u5b89\u88c5\u6240\u6709\u4f9d\u8d56\u5305\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;rpm&nbsp;-ivh&nbsp;--nodeps&nbsp;*.rpm<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8fdb\u5165\u89e3\u538b\u540e\u7684\u76ee\u5f55\uff0c\u7136\u540e\u6267\u884cNginx\u7684\u914d\u7f6e\u811a\u672c\uff0c\u4e3a\u540e\u7eed\u7684\u5b89\u88c5\u63d0\u524d\u914d\u7f6e\u597d\u73af\u5883\uff0c\u9ed8\u8ba4\u4f4d\u4e8e\/usr\/local\/nginx\/\u76ee\u5f55\u4e0b\uff08\u53ef\u81ea\u5b9a\u4e49\u76ee\u5f55\uff09\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;cd&nbsp;nginx-1.21.6&nbsp;&nbsp;\n[root@localhost]#&nbsp;.\/configure&nbsp;--prefix=\/soft\/nginx\/<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7f16\u8bd1\u5e76\u5b89\u88c5Nginx\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;make&nbsp;&amp;amp;&amp;amp;&nbsp;make&nbsp;install<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6700\u540e\u56de\u5230\u524d\u9762\u7684\/soft\/nginx\/\u76ee\u5f55\uff0c\u8f93\u5165ls\u5373\u53ef\u770b\u89c1\u5b89\u88c5nginx\u5b8c\u6210\u540e\u751f\u6210\u7684\u6587\u4ef6\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4fee\u6539\u5b89\u88c5\u540e\u751f\u6210\u7684conf\u76ee\u5f55\u4e0b\u7684nginx.conf\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;vi&nbsp;conf\/nginx.conf&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;\u4fee\u6539\u7aef\u53e3\u53f7\uff1alisten&nbsp;&nbsp;&nbsp;&nbsp;80;&nbsp;&nbsp;\n&nbsp;\u4fee\u6539IP\u5730\u5740\uff1aserver_name&nbsp;&nbsp;\u4f60\u5f53\u524d\u673a\u5668\u7684\u672c\u5730IP(\u7ebf\u4e0a\u914d\u7f6e\u57df\u540d);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5236\u5b9a\u914d\u7f6e\u6587\u4ef6\u5e76\u542f\u52a8Nginx\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;sbin\/nginx&nbsp;-c&nbsp;conf\/nginx.conf&nbsp;&nbsp;\n[root@localhost]#&nbsp;ps&nbsp;aux&nbsp;|&nbsp;grep&nbsp;nginx<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">Nginx\u5176\u4ed6\u64cd\u4f5c\u547d\u4ee4\uff1a<\/p>\n<pre>sbin\/nginx&nbsp;-t&nbsp;-c&nbsp;conf\/nginx.conf&nbsp;#&nbsp;\u68c0\u6d4b\u914d\u7f6e\u6587\u4ef6\u662f\u5426\u6b63\u5e38&nbsp;&nbsp;\nsbin\/nginx&nbsp;-s&nbsp;reload&nbsp;-c&nbsp;conf\/nginx.conf&nbsp;#&nbsp;\u4fee\u6539\u914d\u7f6e\u540e\u5e73\u6ed1\u91cd\u542f&nbsp;&nbsp;\nsbin\/nginx&nbsp;-s&nbsp;quit&nbsp;#&nbsp;\u4f18\u96c5\u5173\u95edNginx\uff0c\u4f1a\u5728\u6267\u884c\u5b8c\u5f53\u524d\u7684\u4efb\u52a1\u540e\u518d\u9000\u51fa&nbsp;&nbsp;\nsbin\/nginx&nbsp;-s&nbsp;stop&nbsp;#&nbsp;\u5f3a\u5236\u7ec8\u6b62Nginx\uff0c\u4e0d\u7ba1\u5f53\u524d\u662f\u5426\u6709\u4efb\u52a1\u5728\u6267\u884c<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5f00\u653e80\u7aef\u53e3\uff0c\u5e76\u66f4\u65b0\u9632\u706b\u5899\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;firewall-cmd&nbsp;--zone=public&nbsp;--add-port=80\/tcp&nbsp;--permanent&nbsp;&nbsp;\n[root@localhost]#&nbsp;firewall-cmd&nbsp;--reload&nbsp;&nbsp;\n[root@localhost]#&nbsp;firewall-cmd&nbsp;--zone=public&nbsp;--list-ports<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u24eb\u5728Windows\/Mac\u7684\u6d4f\u89c8\u5668\u4e2d\uff0c\u76f4\u63a5\u8f93\u5165\u521a\u521a\u914d\u7f6e\u7684IP\u5730\u5740\u8bbf\u95eeNginx\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6700\u7ec8\u770b\u5230\u5982\u4e0a\u7684Nginx\u6b22\u8fce\u754c\u9762\uff0c\u4ee3\u8868Nginx\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n<h3> <span><\/span>\u4e09\u3001Nginx\u53cd\u5411\u4ee3\u7406-\u8d1f\u8f7d\u5747\u8861<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u9996\u5148\u901a\u8fc7SpringBoot+Freemarker\u5feb\u901f\u642d\u5efa\u4e00\u4e2aWEB\u9879\u76ee\uff1aspringboot-web-nginx\uff0c\u7136\u540e\u5728\u8be5\u9879\u76ee\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2aIndexNginxController.java\u6587\u4ef6\uff0c\u903b\u8f91\u5982\u4e0b\uff1a<\/p>\n<pre>@Controller&nbsp;&nbsp;\npublic&nbsp;class&nbsp;IndexNginxController&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;@Value(\"${server.port}\")&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;String&nbsp;port;&nbsp;&nbsp;\n&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;@RequestMapping(\"\/\")&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;ModelAndView&nbsp;index(){&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ModelAndView&nbsp;model&nbsp;=&nbsp;new&nbsp;ModelAndView();&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;model.addObject(\"port\",&nbsp;port);&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;model.setViewName(\"index\");&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;model;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728\u8be5Controller\u7c7b\u4e2d\uff0c\u5b58\u5728\u4e00\u4e2a\u6210\u5458\u53d8\u91cf\uff1aport\uff0c\u5b83\u7684\u503c\u5373\u662f\u4eceapplication.properties\u914d\u7f6e\u6587\u4ef6\u4e2d\u83b7\u53d6server.port\u503c\u3002\u5f53\u51fa\u73b0\u8bbf\u95ee\/\u8d44\u6e90\u7684\u8bf7\u6c42\u65f6\uff0c\u8df3\u8f6c\u524d\u7aefindex\u9875\u9762\uff0c\u5e76\u5c06\u8be5\u503c\u643a\u5e26\u8fd4\u56de\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u524d\u7aef\u7684index.ftl\u6587\u4ef6\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;Nginx\u6f14\u793a\u9875\u9762&lt;\/title&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;link&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;\u6b22\u8fce\u6765\u5230\u718a\u732b\u9ad8\u7ea7\u4f1a\u6240\uff0c\u6211\u662f\u7af9\u5b50${port}\u53f7\uff01&lt;\/h1&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/div&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/div&gt;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4ece\u4e0a\u53ef\u4ee5\u770b\u51fa\u5176\u903b\u8f91\u5e76\u4e0d\u590d\u6742\uff0c\u4ec5\u662f\u4ece\u54cd\u5e94\u4e2d\u83b7\u53d6\u4e86port\u8f93\u51fa\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">OK~\uff0c\u524d\u63d0\u5de5\u4f5c\u51c6\u5907\u5c31\u7eea\u540e\uff0c\u518d\u7b80\u5355\u4fee\u6539\u4e00\u4e0bnginx.conf\u7684\u914d\u7f6e\u5373\u53ef\uff1a<\/p>\n<pre>upstream&nbsp;nginx_boot{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;#&nbsp;30s\u5185\u68c0\u67e5\u5fc3\u8df3\u53d1\u9001\u4e24\u6b21\u5305\uff0c\u672a\u56de\u590d\u5c31\u4ee3\u8868\u8be5\u673a\u5668\u5b95\u673a\uff0c\u8bf7\u6c42\u5206\u53d1\u6743\u91cd\u6bd4\u4e3a1:2&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;server&nbsp;192.168.0.000:8080&nbsp;weight=100&nbsp;max_fails=2&nbsp;fail_timeout=30s;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;server&nbsp;192.168.0.000:8090&nbsp;weight=200&nbsp;max_fails=2&nbsp;fail_timeout=30s;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;#&nbsp;\u8fd9\u91cc\u7684IP\u8bf7\u914d\u7f6e\u6210\u4f60WEB\u670d\u52a1\u6240\u5728\u7684\u673a\u5668IP&nbsp;&nbsp;\n}&nbsp;&nbsp;\n&nbsp;&nbsp;\nserver&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;html;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u914d\u7f6e\u4e00\u4e0bindex\u7684\u5730\u5740\uff0c\u6700\u540e\u52a0\u4e0aindex.ftl\u3002&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;&nbsp;index.html&nbsp;index.htm&nbsp;index.jsp&nbsp;index.ftl;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;Host&nbsp;$host;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;X-Real-IP&nbsp;$remote_addr;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;X-Forwarded-For&nbsp;$proxy_add_x_forwarded_for;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8bf7\u6c42\u4ea4\u7ed9\u540d\u4e3anginx_boot\u7684upstream\u4e0a&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;http:\/\/nginx_boot;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u81f3\u6b64\uff0c\u6240\u6709\u7684\u524d\u63d0\u5de5\u4f5c\u51c6\u5907\u5c31\u7eea\uff0c\u7d27\u63a5\u7740\u518d\u542f\u52a8Nginx\uff0c\u7136\u540e\u518d\u542f\u52a8\u4e24\u4e2aweb\u670d\u52a1\uff0c\u7b2c\u4e00\u4e2aWEB\u670d\u52a1\u542f\u52a8\u65f6\uff0c\u5728application.properties\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u5c06\u7aef\u53e3\u53f7\u6539\u4e3a8080\uff0c\u7b2c\u4e8c\u4e2aWEB\u670d\u52a1\u542f\u52a8\u65f6\uff0c\u5c06\u5176\u7aef\u53e3\u53f7\u6539\u4e3a8090\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6700\u7ec8\u6765\u770b\u770b\u6548\u679c\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/96577c36b9115f3c2739f53689db531f-2.gif\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe2\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe2\" \/>\u8d1f\u8f7d\u5747\u8861\u6548\u679c-\u52a8\u56fe\u6f14\u793a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u56e0\u4e3a\u914d\u7f6e\u4e86\u8bf7\u6c42\u5206\u53d1\u7684\u6743\u91cd\uff0c8080\u30018090\u7684\u6743\u91cd\u6bd4\u4e3a2:1\uff0c\u56e0\u6b64\u8bf7\u6c42\u4f1a\u6839\u636e\u6743\u91cd\u6bd4\u5747\u644a\u5230\u6bcf\u53f0\u673a\u5668\uff0c\u4e5f\u5c31\u662f8080\u4e00\u6b21\u30018090\u4e24\u6b21\u30018080\u4e00\u6b21&#8230;&#8230;<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>Java\u5f00\u53d1\u8005\u5728\u7ebf\u5237\u9898\u795e\u5668<\/strong><\/p>\n<h4> <span><\/span>Nginx\u8bf7\u6c42\u5206\u53d1\u539f\u7406<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5ba2\u6237\u7aef\u53d1\u51fa\u7684\u8bf7\u6c42192.168.12.129\u6700\u7ec8\u4f1a\u8f6c\u53d8\u4e3a\uff1ahttp:\/\/192.168.12.129:80\/\uff0c\u7136\u540e\u518d\u5411\u76ee\u6807IP\u53d1\u8d77\u8bf7\u6c42\uff0c\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/96577c36b9115f3c2739f53689db531f-3.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe3\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe3\" \/>\u8bf7\u6c42\u5206\u53d1\u539f\u7406<\/p>\n<ul>\n<li> \u7531\u4e8eNginx\u76d1\u542c\u4e86192.168.12.129\u768480\u7aef\u53e3\uff0c\u6240\u4ee5\u6700\u7ec8\u8be5\u8bf7\u6c42\u4f1a\u627e\u5230Nginx\u8fdb\u7a0b\uff1b <\/li>\n<li> Nginx\u9996\u5148\u4f1a\u6839\u636e\u914d\u7f6e\u7684location\u89c4\u5219\u8fdb\u884c\u5339\u914d\uff0c\u6839\u636e\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u8def\u5f84\/\uff0c\u4f1a\u5b9a\u4f4d\u5230location \/{}\u89c4\u5219\uff1b <\/li>\n<li> \u7136\u540e\u6839\u636e\u8be5location\u4e2d\u914d\u7f6e\u7684proxy_pass\u4f1a\u518d\u627e\u5230\u540d\u4e3anginx_boot\u7684upstream\uff1b <\/li>\n<li> \u6700\u540e\u6839\u636eupstream\u4e2d\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u5c06\u8bf7\u6c42\u8f6c\u53d1\u5230\u8fd0\u884cWEB\u670d\u52a1\u7684\u673a\u5668\u5904\u7406\uff0c\u7531\u4e8e\u914d\u7f6e\u4e86\u591a\u4e2aWEB\u670d\u52a1\uff0c\u4e14\u914d\u7f6e\u4e86\u6743\u91cd\u503c\uff0c\u56e0\u6b64Nginx\u4f1a\u4f9d\u6b21\u6839\u636e\u6743\u91cd\u6bd4\u5206\u53d1\u8bf7\u6c42\u3002 <\/li>\n<\/ul>\n<h3> <span><\/span>\u56db\u3001Nginx\u52a8\u9759\u5206\u79bb<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u52a8\u9759\u5206\u79bb\u5e94\u8be5\u662f\u542c\u7684\u6b21\u6570\u8f83\u591a\u7684\u6027\u80fd\u4f18\u5316\u65b9\u6848\uff0c\u90a3\u5148\u601d\u8003\u4e00\u4e2a\u95ee\u9898\uff1a<strong>\u300c\u300c\u4e3a\u4ec0\u4e48\u9700\u8981\u505a\u52a8\u9759\u5206\u79bb\u5462\uff1f\u5b83\u5e26\u6765\u7684\u597d\u5904\u662f\u4ec0\u4e48\uff1f\u300d\u300d<\/strong> \u5176\u5b9e\u8fd9\u4e2a\u95ee\u9898\u4e5f\u5e76\u4e0d\u96be\u56de\u7b54\uff0c\u5f53\u4f60\u641e\u61c2\u4e86\u7f51\u7ad9\u7684\u672c\u8d28\u540e\uff0c\u81ea\u7136\u5c31\u7406\u89e3\u4e86\u52a8\u9759\u5206\u79bb\u7684\u91cd\u8981\u6027\u3002\u5148\u6765\u4ee5\u6dd8\u5b9d\u4e3a\u4f8b\u5206\u6790\u770b\u770b\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/96577c36b9115f3c2739f53689db531f-4.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe4\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe4\" \/>\u6dd8\u5b9d\u9996\u9875<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5f53\u6d4f\u89c8\u5668\u8f93\u5165www.taobao.com\u8bbf\u95ee\u6dd8\u5b9d\u9996\u9875\u65f6\uff0c\u6253\u5f00\u5f00\u53d1\u8005\u8c03\u8bd5\u5de5\u5177\u53ef\u4ee5\u5f88\u660e\u663e\u7684\u770b\u5230\uff0c\u9996\u9875\u52a0\u8f7d\u4f1a\u51fa\u73b0100+\u7684\u8bf7\u6c42\u6570\uff0c\u800c\u6b63\u5e38\u9879\u76ee\u5f00\u53d1\u65f6\uff0c\u9759\u6001\u8d44\u6e90\u4e00\u822c\u4f1a\u653e\u5165\u5230resources\/static\/\u76ee\u5f55\u4e0b\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/cdda5c10b448e5a6e017d154d6edf3cb-5.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe5\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe5\" \/>IDEA \u5de5\u7a0b\u7ed3\u6784<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728\u9879\u76ee\u4e0a\u7ebf\u90e8\u7f72\u65f6\uff0c\u8fd9\u4e9b\u9759\u6001\u8d44\u6e90\u4f1a\u4e00\u8d77\u6253\u6210\u5305\uff0c\u90a3\u6b64\u65f6\u601d\u8003\u4e00\u4e2a\u95ee\u9898\uff1a<strong>\u300c\u300c\u5047\u8bbe\u6dd8\u5b9d\u4e5f\u662f\u8fd9\u6837\u5e72\u7684\uff0c\u90a3\u4e48\u9996\u9875\u52a0\u8f7d\u65f6\u7684\u8bf7\u6c42\u6700\u7ec8\u4f1a\u53bb\u5230\u54ea\u513f\u88ab\u5904\u7406\uff1f\u300d\u300d<\/strong> \u7b54\u6848\u6bcb\u5eb8\u7f6e\u7591\uff0c\u9996\u9875100+\u7684\u6240\u6709\u8bf7\u6c42\u90fd\u4f1a\u6765\u5230\u90e8\u7f72WEB\u670d\u52a1\u7684\u673a\u5668\u5904\u7406\uff0c\u90a3\u5219\u4ee3\u8868\u7740\u4e00\u4e2a\u5ba2\u6237\u7aef\u8bf7\u6c42\u6dd8\u5b9d\u9996\u9875\uff0c\u5c31\u4f1a\u5bf9\u540e\u7aef\u670d\u52a1\u5668\u9020\u6210100+\u7684\u5e76\u53d1\u8bf7\u6c42\u3002\u6beb\u65e0\u7591\u95ee\uff0c\u8fd9\u5bf9\u4e8e\u540e\u7aef\u670d\u52a1\u5668\u7684\u538b\u529b\u662f\u5c24\u4e3a\u5de8\u5927\u7684\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4f46\u6b64\u65f6\u4e0d\u59a8\u5206\u6790\u770b\u770b\uff0c\u9996\u9875100+\u7684\u8bf7\u6c42\u4e2d\uff0c\u662f\u4e0d\u662f\u81f3\u5c11\u670960+\u662f\u5c5e\u4e8e*.js\u3001*.css\u3001*.html\u3001*.jpg&#8230;..\u8fd9\u7c7b\u9759\u6001\u8d44\u6e90\u7684\u8bf7\u6c42\u5462\uff1f\u7b54\u6848\u662fYes\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u65e2\u7136\u6709\u8fd9\u4e48\u591a\u8bf7\u6c42\u5c5e\u4e8e\u9759\u6001\u7684\uff0c\u8fd9\u4e9b\u8d44\u6e90\u5927\u6982\u7387\u60c5\u51b5\u4e0b\uff0c\u957f\u65f6\u95f4\u4e5f\u4e0d\u4f1a\u51fa\u73b0\u53d8\u52a8\uff0c\u90a3\u4e3a\u4f55\u8fd8\u8981\u8ba9\u8fd9\u4e9b\u8bf7\u6c42\u5230\u540e\u7aef\u518d\u5904\u7406\u5462\uff1f\u80fd\u4e0d\u80fd\u5728\u6b64\u4e4b\u524d\u5c31\u63d0\u524d\u5904\u7406\u6389\uff1f\u5f53\u7136OK\uff0c\u56e0\u6b64\u7ecf\u8fc7\u5206\u6790\u4e4b\u540e\u80fd\u591f\u660e\u786e\u4e00\u70b9\uff1a<strong>\u300c\u300c\u505a\u4e86\u52a8\u9759\u5206\u79bb\u4e4b\u540e\uff0c\u81f3\u5c11\u80fd\u591f\u8ba9\u540e\u7aef\u670d\u52a1\u51cf\u5c11\u4e00\u534a\u4ee5\u4e0a\u7684\u5e76\u53d1\u91cf\u3002\u300d\u300d<\/strong> \u5230\u6b64\u65f6\u5927\u5bb6\u5e94\u8be5\u660e\u767d\u4e86\u52a8\u9759\u5206\u79bb\u80fd\u591f\u5e26\u6765\u7684\u6027\u80fd\u6536\u76ca\u7a76\u7adf\u6709\u591a\u5927\u3002<\/p>\n<hr>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">OK~\uff0c\u641e\u6e05\u695a\u52a8\u9759\u5206\u79bb\u7684\u5fc5\u8981\u6027\u4e4b\u540e\uff0c\u5982\u4f55\u5b9e\u73b0\u52a8\u9759\u5206\u79bb\u5462\uff1f\u5176\u5b9e\u975e\u5e38\u7b80\u5355\uff0c\u5b9e\u6218\u770b\u770b\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2460\u5148\u5728\u90e8\u7f72Nginx\u7684\u673a\u5668\uff0cNginx\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u76ee\u5f55static_resources\uff1a<\/p>\n<pre>mkdir&nbsp;static_resources<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2461\u5c06\u9879\u76ee\u4e2d\u6240\u6709\u7684\u9759\u6001\u8d44\u6e90\u5168\u90e8\u62f7\u8d1d\u5230\u8be5\u76ee\u5f55\u4e0b\uff0c\u800c\u540e\u5c06\u9879\u76ee\u4e2d\u7684\u9759\u6001\u8d44\u6e90\u79fb\u9664\u91cd\u65b0\u6253\u5305\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2462\u7a0d\u5fae\u4fee\u6539\u4e00\u4e0bnginx.conf\u7684\u914d\u7f6e\uff0c\u589e\u52a0\u4e00\u6761location\u5339\u914d\u89c4\u5219\uff1a<\/p>\n<pre>location&nbsp;~&nbsp;.*.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css){&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;\/soft\/nginx\/static_resources;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;expires&nbsp;7d;&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7136\u540e\u7167\u5e38\u542f\u52a8nginx\u548c\u79fb\u9664\u4e86\u9759\u6001\u8d44\u6e90\u7684WEB\u670d\u52a1\uff0c\u4f60\u4f1a\u53d1\u73b0\u539f\u672c\u7684\u6837\u5f0f\u3001js\u6548\u679c\u3001\u56fe\u7247\u7b49\u4f9d\u65e7\u6709\u6548\uff0c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/cdda5c10b448e5a6e017d154d6edf3cb-6.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe6\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe6\" \/> <\/p>\n<p style=\"max-width:90%\">\u5176\u4e2dstatic\u76ee\u5f55\u4e0b\u7684nginx_style.css\u6587\u4ef6\u5df2\u88ab\u79fb\u9664\uff0c\u4f46\u6548\u679c\u4f9d\u65e7\u5b58\u5728\uff08\u7eff\u8272\u5b57\u4f53+\u84dd\u8272\u5927\u8fb9\u6846)\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/cdda5c10b448e5a6e017d154d6edf3cb-7.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe7\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe7\" \/>\u79fb\u9664\u540e\u6548\u679c\u52a8\u56fe<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6700\u540e\u89e3\u8bfb\u4e00\u4e0b\u90a3\u6761location\u89c4\u5219\uff1a<\/p>\n<pre>location&nbsp;~&nbsp;.*.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> ~\u4ee3\u8868\u5339\u914d\u65f6\u533a\u5206\u5927\u5c0f\u5199 <\/li>\n<li> .*\u4ee3\u8868\u4efb\u610f\u5b57\u7b26\u90fd\u53ef\u4ee5\u51fa\u73b0\u96f6\u6b21\u6216\u591a\u6b21\uff0c\u5373\u8d44\u6e90\u540d\u4e0d\u9650\u5236 <\/li>\n<li> .\u4ee3\u8868\u5339\u914d\u540e\u7f00\u5206\u9694\u7b26. <\/li>\n<li> (html|&#8230;|css)\u4ee3\u8868\u5339\u914d\u62ec\u53f7\u91cc\u6240\u6709\u9759\u6001\u8d44\u6e90\u7c7b\u578b <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7efc\u4e0a\u6240\u8ff0\uff0c\u7b80\u5355\u4e00\u53e5\u8bdd\u6982\u8ff0\uff1a\u8be5\u914d\u7f6e\u8868\u793a\u5339\u914d\u4ee5.html~.css\u4e3a\u540e\u7f00\u7684\u6240\u6709\u8d44\u6e90\u8bf7\u6c42\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300c\u6700\u540e\u63d0\u4e00\u5634\uff0c\u4e5f\u53ef\u4ee5\u5c06\u9759\u6001\u8d44\u6e90\u4e0a\u4f20\u5230\u6587\u4ef6\u670d\u52a1\u5668\u4e2d\uff0c\u7136\u540elocation\u4e2d\u914d\u7f6e\u4e00\u4e2a\u65b0\u7684upstream\u6307\u5411\u3002\u300d<\/strong><\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong><strong>Java\u5f00\u53d1\u8005\u5728\u7ebf\u5237\u9898\u795e\u5668<\/strong><\/strong><\/p>\n<h3> <span><\/span>\u4e94\u3001Nginx\u8d44\u6e90\u538b\u7f29<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5efa\u7acb\u5728\u52a8\u9759\u5206\u79bb\u7684\u57fa\u7840\u4e4b\u4e0a\uff0c\u5982\u679c\u4e00\u4e2a\u9759\u6001\u8d44\u6e90\u7684Size\u8d8a\u5c0f\uff0c\u90a3\u4e48\u81ea\u7136\u4f20\u8f93\u901f\u5ea6\u4f1a\u66f4\u5feb\uff0c\u540c\u65f6\u4e5f\u4f1a\u66f4\u8282\u7701\u5e26\u5bbd\uff0c\u56e0\u6b64\u6211\u4eec\u5728\u90e8\u7f72\u9879\u76ee\u65f6\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7Nginx\u5bf9\u4e8e\u9759\u6001\u8d44\u6e90\u5b9e\u73b0\u538b\u7f29\u4f20\u8f93\uff0c\u4e00\u65b9\u9762\u53ef\u4ee5\u8282\u7701\u5e26\u5bbd\u8d44\u6e90\uff0c\u7b2c\u4e8c\u65b9\u9762\u4e5f\u53ef\u4ee5\u52a0\u5feb\u54cd\u5e94\u901f\u5ea6\u5e76\u63d0\u5347\u7cfb\u7edf\u6574\u4f53\u541e\u5410\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728Nginx\u4e5f\u63d0\u4f9b\u4e86\u4e09\u4e2a\u652f\u6301\u8d44\u6e90\u538b\u7f29\u7684\u6a21\u5757ngx_http_gzip_module\u3001ngx_http_gzip_static_module\u3001ngx_http_gunzip_module\uff0c\u5176\u4e2dngx_http_gzip_module\u5c5e\u4e8e\u5185\u7f6e\u6a21\u5757\uff0c\u4ee3\u8868\u7740\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u8be5\u6a21\u5757\u4e0b\u7684\u4e00\u4e9b\u538b\u7f29\u6307\u4ee4\uff0c\u540e\u7eed\u7684\u8d44\u6e90\u538b\u7f29\u64cd\u4f5c\u90fd\u57fa\u4e8e\u8be5\u6a21\u5757\uff0c\u5148\u6765\u770b\u770b\u538b\u7f29\u914d\u7f6e\u7684\u4e00\u4e9b\u53c2\u6570\/\u6307\u4ee4\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/32d6bb0778f2bbbf0e7b3133173b0317-8.png\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe8\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe8\" \/> <\/p>\n<p style=\"max-width:90%\">\u4e86\u89e3\u4e86Nginx\u4e2d\u7684\u57fa\u672c\u538b\u7f29\u914d\u7f6e\u540e\uff0c\u63a5\u4e0b\u6765\u53ef\u4ee5\u5728Nginx\u4e2d\u7b80\u5355\u914d\u7f6e\u4e00\u4e0b\uff1a<\/p>\n<pre>http{\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5f00\u542f\u538b\u7f29\u673a\u5236\n&nbsp;&nbsp;&nbsp;&nbsp;gzip&nbsp;on;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6307\u5b9a\u4f1a\u88ab\u538b\u7f29\u7684\u6587\u4ef6\u7c7b\u578b(\u4e5f\u53ef\u81ea\u5df1\u914d\u7f6e\u5176\u4ed6\u7c7b\u578b)\n&nbsp;&nbsp;&nbsp;&nbsp;gzip_types&nbsp;text\/plain&nbsp;application\/javascript&nbsp;text\/css&nbsp;application\/xml&nbsp;text\/javascript&nbsp;image\/jpeg&nbsp;image\/gif&nbsp;image\/png;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8bbe\u7f6e\u538b\u7f29\u7ea7\u522b\uff0c\u8d8a\u9ad8\u8d44\u6e90\u6d88\u8017\u8d8a\u5927\uff0c\u4f46\u538b\u7f29\u6548\u679c\u8d8a\u597d\n&nbsp;&nbsp;&nbsp;&nbsp;gzip_comp_level&nbsp;5;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5728\u5934\u90e8\u4e2d\u6dfb\u52a0Vary:&nbsp;Accept-Encoding\uff08\u5efa\u8bae\u5f00\u542f\uff09\n&nbsp;&nbsp;&nbsp;&nbsp;gzip_vary&nbsp;on;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5904\u7406\u538b\u7f29\u8bf7\u6c42\u7684\u7f13\u51b2\u533a\u6570\u91cf\u548c\u5927\u5c0f\n&nbsp;&nbsp;&nbsp;&nbsp;gzip_buffers&nbsp;16&nbsp;8k;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5bf9\u4e8e\u4e0d\u652f\u6301\u538b\u7f29\u529f\u80fd\u7684\u5ba2\u6237\u7aef\u8bf7\u6c42\u4e0d\u5f00\u542f\u538b\u7f29\u673a\u5236\n&nbsp;&nbsp;&nbsp;&nbsp;gzip_disable&nbsp;\"MSIE&nbsp;[1-6].\";&nbsp;#&nbsp;\u4f4e\u7248\u672c\u7684IE\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u538b\u7f29\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8bbe\u7f6e\u538b\u7f29\u54cd\u5e94\u6240\u652f\u6301\u7684HTTP\u6700\u4f4e\u7248\u672c\n&nbsp;&nbsp;&nbsp;&nbsp;gzip_http_version&nbsp;1.1;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8bbe\u7f6e\u89e6\u53d1\u538b\u7f29\u7684\u6700\u5c0f\u9608\u503c\n&nbsp;&nbsp;&nbsp;&nbsp;gzip_min_length&nbsp;2k;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5173\u95ed\u5bf9\u540e\u7aef\u670d\u52a1\u5668\u7684\u54cd\u5e94\u7ed3\u679c\u8fdb\u884c\u538b\u7f29\n&nbsp;&nbsp;&nbsp;&nbsp;gzip_proxied&nbsp;off;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728\u4e0a\u8ff0\u7684\u538b\u7f29\u914d\u7f6e\u4e2d\uff0c\u6700\u540e\u4e00\u4e2agzip_proxied\u9009\u9879\uff0c\u53ef\u4ee5\u6839\u636e\u7cfb\u7edf\u7684\u5b9e\u9645\u60c5\u51b5\u51b3\u5b9a\uff0c\u603b\u5171\u5b58\u5728\u591a\u79cd\u9009\u9879\uff1a<\/p>\n<ul>\n<li> off\uff1a\u5173\u95edNginx\u5bf9\u540e\u53f0\u670d\u52a1\u5668\u7684\u54cd\u5e94\u7ed3\u679c\u8fdb\u884c\u538b\u7f29\u3002 <\/li>\n<li> expired\uff1a\u5982\u679c\u54cd\u5e94\u5934\u4e2d\u5305\u542bExpires\u4fe1\u606f\uff0c\u5219\u5f00\u542f\u538b\u7f29\u3002 <\/li>\n<li> no-cache\uff1a\u5982\u679c\u54cd\u5e94\u5934\u4e2d\u5305\u542bCache-Control:no-cache\u4fe1\u606f\uff0c\u5219\u5f00\u542f\u538b\u7f29\u3002 <\/li>\n<li> no-store\uff1a\u5982\u679c\u54cd\u5e94\u5934\u4e2d\u5305\u542bCache-Control:no-store\u4fe1\u606f\uff0c\u5219\u5f00\u542f\u538b\u7f29\u3002 <\/li>\n<li> private\uff1a\u5982\u679c\u54cd\u5e94\u5934\u4e2d\u5305\u542bCache-Control:private\u4fe1\u606f\uff0c\u5219\u5f00\u542f\u538b\u7f29\u3002 <\/li>\n<li> no_last_modified\uff1a\u5982\u679c\u54cd\u5e94\u5934\u4e2d\u4e0d\u5305\u542bLast-Modified\u4fe1\u606f\uff0c\u5219\u5f00\u542f\u538b\u7f29\u3002 <\/li>\n<li> no_etag\uff1a\u5982\u679c\u54cd\u5e94\u5934\u4e2d\u4e0d\u5305\u542bETag\u4fe1\u606f\uff0c\u5219\u5f00\u542f\u538b\u7f29\u3002 <\/li>\n<li> auth\uff1a\u5982\u679c\u54cd\u5e94\u5934\u4e2d\u5305\u542bAuthorization\u4fe1\u606f\uff0c\u5219\u5f00\u542f\u538b\u7f29\u3002 <\/li>\n<li> any\uff1a\u65e0\u6761\u4ef6\u5bf9\u540e\u7aef\u7684\u54cd\u5e94\u7ed3\u679c\u5f00\u542f\u538b\u7f29\u673a\u5236\u3002 <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">OK~\uff0c\u7b80\u5355\u4fee\u6539\u597d\u4e86Nginx\u7684\u538b\u7f29\u914d\u7f6e\u540e\uff0c\u53ef\u4ee5\u5728\u539f\u672c\u7684index\u9875\u9762\u4e2d\u5f15\u5165\u4e00\u4e2ajquery-3.6.0.js\u6587\u4ef6\uff1a<\/p>\n<pre>&lt;script&gt;&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5206\u522b\u6765\u5bf9\u6bd4\u4e0b\u538b\u7f29\u524d\u540e\u7684\u533a\u522b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/32d6bb0778f2bbbf0e7b3133173b0317-9.png\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe9\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe9\" \/> \u56fe\u7247 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4ece\u56fe\u4e2d\u53ef\u4ee5\u5f88\u660e\u663e\u770b\u51fa\uff0c\u672a\u5f00\u542f\u538b\u7f29\u673a\u5236\u524d\u8bbf\u95ee\u65f6\uff0cjs\u6587\u4ef6\u7684\u539f\u59cb\u5927\u5c0f\u4e3a230K\uff0c\u5f53\u914d\u7f6e\u597d\u538b\u7f29\u540e\u518d\u91cd\u542fNginx\uff0c\u4f1a\u53d1\u73b0\u6587\u4ef6\u5927\u5c0f\u4ece230KB\u219269KB\uff0c\u6548\u679c\u7acb\u7aff\u89c1\u5f71\uff01<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6ce8\u610f\u70b9\uff1a\u2460\u5bf9\u4e8e\u56fe\u7247\u3001\u89c6\u9891\u7c7b\u578b\u7684\u6570\u636e\uff0c\u4f1a\u9ed8\u8ba4\u5f00\u542f\u538b\u7f29\u673a\u5236\uff0c\u56e0\u6b64\u4e00\u822c\u65e0\u9700\u518d\u6b21\u5f00\u542f\u538b\u7f29\u3002\u2461\u5bf9\u4e8e.js\u6587\u4ef6\u800c\u8a00\uff0c\u9700\u8981\u6307\u5b9a\u538b\u7f29\u7c7b\u578b\u4e3aapplication\/javascript\uff0c\u800c\u5e76\u975etext\/javascript\u3001application\/x-javascript\u3002<\/p>\n<h3> <span><\/span>\u516d\u3001Nginx\u7f13\u51b2\u533a<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5148\u6765\u601d\u8003\u4e00\u4e2a\u95ee\u9898\uff0c\u63a5\u5165Nginx\u7684\u9879\u76ee\u4e00\u822c\u8bf7\u6c42\u6d41\u7a0b\u4e3a\uff1a\u201c\u5ba2\u6237\u7aef\u2192Nginx\u2192\u670d\u52a1\u7aef\u201d\uff0c\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u5b58\u5728\u4e24\u4e2a\u8fde\u63a5\uff1a\u201c\u5ba2\u6237\u7aef\u2192Nginx\u3001Nginx\u2192\u670d\u52a1\u7aef\u201d\uff0c\u90a3\u4e48\u4e24\u4e2a\u4e0d\u540c\u7684\u8fde\u63a5\u901f\u5ea6\u4e0d\u4e00\u81f4\uff0c\u5c31\u4f1a\u5f71\u54cd\u7528\u6237\u7684\u4f53\u9a8c\uff08\u6bd4\u5982\u6d4f\u89c8\u5668\u7684\u52a0\u8f7d\u901f\u5ea6\u8ddf\u4e0d\u4e0a\u670d\u52a1\u7aef\u7684\u54cd\u5e94\u901f\u5ea6\uff09\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5176\u5b9e\u4e5f\u5c31\u7c7b\u4f3c\u7535\u8111\u7684\u5185\u5b58\u8ddf\u4e0d\u4e0aCPU\u901f\u5ea6\uff0c\u6240\u4ee5\u5bf9\u4e8e\u7528\u6237\u9020\u6210\u7684\u4f53\u9a8c\u611f\u6781\u5dee\uff0c\u56e0\u6b64\u5728CPU\u8bbe\u8ba1\u65f6\u90fd\u4f1a\u52a0\u5165\u4e09\u7ea7\u9ad8\u901f\u7f13\u51b2\u533a\uff0c\u7528\u4e8e\u7f13\u89e3CPU\u548c\u5185\u5b58\u901f\u7387\u4e0d\u4e00\u81f4\u7684\u77db\u76fe\u3002\u5728Nginx\u4e5f\u540c\u6837\u5b58\u5728\u7f13\u51b2\u533a\u7684\u673a\u5236\uff0c\u4e3b\u8981\u76ee\u7684\u5c31\u5728\u4e8e\uff1a<strong>\u300c\u300c\u7528\u6765\u89e3\u51b3\u4e24\u4e2a\u8fde\u63a5\u4e4b\u95f4\u901f\u5ea6\u4e0d\u5339\u914d\u9020\u6210\u7684\u95ee\u9898\u300d\u300d<\/strong> \uff0c\u6709\u4e86\u7f13\u51b2\u540e\uff0cNginx\u4ee3\u7406\u53ef\u6682\u5b58\u540e\u7aef\u7684\u54cd\u5e94\uff0c\u7136\u540e\u6309\u9700\u4f9b\u7ed9\u6570\u636e\u7ed9\u5ba2\u6237\u7aef\u3002\u5148\u6765\u770b\u770b\u4e00\u4e9b\u5173\u4e8e\u7f13\u51b2\u533a\u7684\u914d\u7f6e\u9879\uff1a<\/p>\n<ul>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">proxy_buffering\uff1a\u662f\u5426\u542f\u7528\u7f13\u51b2\u673a\u5236\uff0c\u9ed8\u8ba4\u4e3aon\u5173\u95ed\u72b6\u6001\u3002<\/p>\n<\/li>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">client_body_buffer_size\uff1a\u8bbe\u7f6e\u7f13\u51b2\u5ba2\u6237\u7aef\u8bf7\u6c42\u6570\u636e\u7684\u5185\u5b58\u5927\u5c0f\u3002<\/p>\n<\/li>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">proxy_buffers\uff1a\u4e3a\u6bcf\u4e2a\u8bf7\u6c42\/\u8fde\u63a5\u8bbe\u7f6e\u7f13\u51b2\u533a\u7684\u6570\u91cf\u548c\u5927\u5c0f\uff0c\u9ed8\u8ba44 4k\/8k\u3002<\/p>\n<\/li>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">proxy_buffer_size\uff1a\u8bbe\u7f6e\u7528\u4e8e\u5b58\u50a8\u54cd\u5e94\u5934\u7684\u7f13\u51b2\u533a\u5927\u5c0f\u3002<\/p>\n<\/li>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">proxy_busy_buffers_size\uff1a\u5728\u540e\u7aef\u6570\u636e\u6ca1\u6709\u5b8c\u5168\u63a5\u6536\u5b8c\u6210\u65f6\uff0cNginx\u53ef\u4ee5\u5c06busy\u72b6\u6001\u7684\u7f13\u51b2\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0c\u8be5\u53c2\u6570\u7528\u6765\u8bbe\u7f6ebusy\u72b6\u6001\u7684buffer\u5177\u4f53\u6709\u591a\u5927\uff0c\u9ed8\u8ba4\u4e3aproxy_buffer_size*2\u3002<\/p>\n<\/li>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">proxy_temp_path\uff1a\u5f53\u5185\u5b58\u7f13\u51b2\u533a\u5b58\u6ee1\u65f6\uff0c\u53ef\u4ee5\u5c06\u6570\u636e\u4e34\u65f6\u5b58\u653e\u5230\u78c1\u76d8\uff0c\u8be5\u53c2\u6570\u662f\u8bbe\u7f6e\u5b58\u50a8\u7f13\u51b2\u6570\u636e\u7684\u76ee\u5f55\u3002<\/p>\n<\/li>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">path\u662f\u4e34\u65f6\u76ee\u5f55\u7684\u8def\u5f84\u3002<\/p>\n<\/li>\n<li> <\/li>\n<ul>\n<li> \u8bed\u6cd5\uff1aproxy_temp_path path; &nbsp;path\u662f\u4e34\u65f6\u76ee\u5f55\u7684\u8def\u5f84 <\/li>\n<\/ul>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">proxy_temp_file_write_size\uff1a\u8bbe\u7f6e\u6bcf\u6b21\u5199\u6570\u636e\u5230\u4e34\u65f6\u6587\u4ef6\u7684\u5927\u5c0f\u9650\u5236\u3002<\/p>\n<\/li>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">proxy_max_temp_file_size\uff1a\u8bbe\u7f6e\u4e34\u65f6\u7684\u7f13\u51b2\u76ee\u5f55\u4e2d\u5141\u8bb8\u5b58\u50a8\u7684\u6700\u5927\u5bb9\u91cf\u3002<\/p>\n<\/li>\n<li>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;color: black\">\u975e\u7f13\u51b2\u53c2\u6570\u9879\uff1a<\/p>\n<\/li>\n<li> <\/li>\n<ul>\n<li> proxy_connect_timeout\uff1a\u8bbe\u7f6e\u4e0e\u540e\u7aef\u670d\u52a1\u5668\u5efa\u7acb\u8fde\u63a5\u65f6\u7684\u8d85\u65f6\u65f6\u95f4\u3002 <\/li>\n<li> proxy_read_timeout\uff1a\u8bbe\u7f6e\u4ece\u540e\u7aef\u670d\u52a1\u5668\u8bfb\u53d6\u54cd\u5e94\u6570\u636e\u7684\u8d85\u65f6\u65f6\u95f4\u3002 <\/li>\n<li> proxy_send_timeout\uff1a\u8bbe\u7f6e\u5411\u540e\u7aef\u670d\u52a1\u5668\u4f20\u8f93\u8bf7\u6c42\u6570\u636e\u7684\u8d85\u65f6\u65f6\u95f4\u3002 <\/li>\n<\/ul>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5177\u4f53\u7684nginx.conf\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<pre>http{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_connect_timeout&nbsp;10;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_read_timeout&nbsp;120;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_send_timeout&nbsp;10;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_buffering&nbsp;on;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;client_body_buffer_size&nbsp;512k;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_buffers&nbsp;4&nbsp;64k;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_buffer_size&nbsp;16k;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_busy_buffers_size&nbsp;128k;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_temp_file_write_size&nbsp;128k;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_temp_path&nbsp;\/soft\/nginx\/temp_buffer;&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4e0a\u8ff0\u7684\u7f13\u51b2\u533a\u53c2\u6570\uff0c\u662f\u57fa\u4e8e\u6bcf\u4e2a\u8bf7\u6c42\u5206\u914d\u7684\u7a7a\u95f4\uff0c\u800c\u5e76\u4e0d\u662f\u6240\u6709\u8bf7\u6c42\u7684\u5171\u4eab\u7a7a\u95f4\u3002\u5f53\u7136\uff0c\u5177\u4f53\u7684\u53c2\u6570\u503c\u8fd8\u9700\u8981\u6839\u636e\u4e1a\u52a1\u53bb\u51b3\u5b9a\uff0c\u8981\u7efc\u5408\u8003\u8651\u673a\u5668\u7684\u5185\u5b58\u4ee5\u53ca\u6bcf\u4e2a\u8bf7\u6c42\u7684\u5e73\u5747\u6570\u636e\u5927\u5c0f\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6700\u540e\u63d0\u4e00\u5634\uff1a\u4f7f\u7528\u7f13\u51b2\u4e5f\u53ef\u4ee5\u51cf\u5c11\u5373\u65f6\u4f20\u8f93\u5e26\u6765\u7684\u5e26\u5bbd\u6d88\u8017\u3002<\/p>\n<h3> <span><\/span>\u4e03\u3001Nginx\u7f13\u5b58\u673a\u5236<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5bf9\u4e8e\u6027\u80fd\u4f18\u5316\u800c\u8a00\uff0c\u7f13\u5b58\u662f\u4e00\u79cd\u80fd\u591f\u5927\u5e45\u5ea6\u63d0\u5347\u6027\u80fd\u7684\u65b9\u6848\uff0c\u56e0\u6b64\u51e0\u4e4e\u53ef\u4ee5\u5728\u5404\u5904\u90fd\u80fd\u770b\u89c1\u7f13\u5b58\uff0c\u5982\u5ba2\u6237\u7aef\u7f13\u5b58\u3001\u4ee3\u7406\u7f13\u5b58\u3001\u670d\u52a1\u5668\u7f13\u5b58\u7b49\u7b49\uff0cNginx\u7684\u7f13\u5b58\u5219\u5c5e\u4e8e\u4ee3\u7406\u7f13\u5b58\u7684\u4e00\u79cd\u3002\u5bf9\u4e8e\u6574\u4e2a\u7cfb\u7edf\u800c\u8a00\uff0c\u52a0\u5165\u7f13\u5b58\u5e26\u6765\u7684\u4f18\u52bf\u989d\u5916\u660e\u663e\uff1a<\/p>\n<ul>\n<li> \u51cf\u5c11\u4e86\u518d\u6b21\u5411\u540e\u7aef\u6216\u6587\u4ef6\u670d\u52a1\u5668\u8bf7\u6c42\u8d44\u6e90\u7684\u5e26\u5bbd\u6d88\u8017\u3002 <\/li>\n<li> \u964d\u4f4e\u4e86\u4e0b\u6e38\u670d\u52a1\u5668\u7684\u8bbf\u95ee\u538b\u529b\uff0c\u63d0\u5347\u7cfb\u7edf\u6574\u4f53\u541e\u5410\u3002 <\/li>\n<li> \u7f29\u77ed\u4e86\u54cd\u5e94\u65f6\u95f4\uff0c\u63d0\u5347\u4e86\u52a0\u8f7d\u901f\u5ea6\uff0c\u6253\u5f00\u9875\u9762\u7684\u901f\u5ea6\u66f4\u5feb\u3002 <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u90a3\u4e48\u5728Nginx\u4e2d\uff0c\u53c8\u8be5\u5982\u4f55\u914d\u7f6e\u4ee3\u7406\u7f13\u5b58\u5462\uff1f\u5148\u6765\u770b\u770b\u7f13\u5b58\u76f8\u5173\u7684\u914d\u7f6e\u9879\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_path\u300d<\/strong>\uff1a\u4ee3\u7406\u7f13\u5b58\u7684\u8def\u5f84\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache_path&nbsp;path&nbsp;[levels=levels]&nbsp;[use_temp_path=on|off]&nbsp;keys_zone=name:size&nbsp;[inactive=time]&nbsp;[max_size=size]&nbsp;[manager_files=number]&nbsp;[manager_sleep=time]&nbsp;[manager_threshold=time]&nbsp;[loader_files=number]&nbsp;[loader_sleep=time]&nbsp;[loader_threshold=time]&nbsp;[purger=on|off]&nbsp;[purger_files=number]&nbsp;[purger_sleep=time]&nbsp;[purger_threshold=time];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u662f\u7684\uff0c\u4f60\u6ca1\u6709\u770b\u9519\uff0c\u5c31\u662f\u8fd9\u4e48\u957f&#8230;.\uff0c\u89e3\u91ca\u4e00\u4e0b\u6bcf\u4e2a\u53c2\u6570\u9879\u7684\u542b\u4e49\uff1a<\/p>\n<ul>\n<li> path\uff1a\u7f13\u5b58\u7684\u8def\u5f84\u5730\u5740\u3002 <\/li>\n<li> levels\uff1a\u7f13\u5b58\u5b58\u50a8\u7684\u5c42\u6b21\u7ed3\u6784\uff0c\u6700\u591a\u5141\u8bb8\u4e09\u5c42\u76ee\u5f55\u3002 <\/li>\n<li> use_temp_path\uff1a\u662f\u5426\u4f7f\u7528\u4e34\u65f6\u76ee\u5f55\u3002 <\/li>\n<li> keys_zone\uff1a\u6307\u5b9a\u4e00\u4e2a\u5171\u4eab\u5185\u5b58\u7a7a\u95f4\u6765\u5b58\u50a8\u70ed\u70b9Key(1M\u53ef\u5b58\u50a88000\u4e2aKey)\u3002 <\/li>\n<li> inactive\uff1a\u8bbe\u7f6e\u7f13\u5b58\u591a\u957f\u65f6\u95f4\u672a\u88ab\u8bbf\u95ee\u540e\u5220\u9664\uff08\u9ed8\u8ba4\u662f\u5341\u5206\u949f\uff09\u3002 <\/li>\n<li> max_size\uff1a\u5141\u8bb8\u7f13\u5b58\u7684\u6700\u5927\u5b58\u50a8\u7a7a\u95f4\uff0c\u8d85\u51fa\u540e\u4f1a\u57fa\u4e8eLRU\u7b97\u6cd5\u79fb\u9664\u7f13\u5b58\uff0cNginx\u4f1a\u521b\u5efa\u4e00\u4e2aCache manager\u7684\u8fdb\u7a0b\u79fb\u9664\u6570\u636e\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7purge\u65b9\u5f0f\u3002 <\/li>\n<li> manager_files\uff1amanager\u8fdb\u7a0b\u6bcf\u6b21\u79fb\u9664\u7f13\u5b58\u6587\u4ef6\u6570\u91cf\u7684\u4e0a\u9650\u3002 <\/li>\n<li> manager_sleep\uff1amanager\u8fdb\u7a0b\u6bcf\u6b21\u79fb\u9664\u7f13\u5b58\u6587\u4ef6\u7684\u65f6\u95f4\u4e0a\u9650\u3002 <\/li>\n<li> manager_threshold\uff1amanager\u8fdb\u7a0b\u6bcf\u6b21\u79fb\u9664\u7f13\u5b58\u540e\u7684\u95f4\u9694\u65f6\u95f4\u3002 <\/li>\n<li> loader_files\uff1a\u91cd\u542fNginx\u8f7d\u5165\u7f13\u5b58\u65f6\uff0c\u6bcf\u6b21\u52a0\u8f7d\u7684\u4e2a\u6570\uff0c\u9ed8\u8ba4100\u3002 <\/li>\n<li> loader_sleep\uff1a\u6bcf\u6b21\u8f7d\u5165\u65f6\uff0c\u5141\u8bb8\u7684\u6700\u5927\u65f6\u95f4\u4e0a\u9650\uff0c\u9ed8\u8ba4200ms\u3002 <\/li>\n<li> loader_threshold\uff1a\u4e00\u6b21\u8f7d\u5165\u540e\uff0c\u505c\u987f\u7684\u65f6\u95f4\u95f4\u9694\uff0c\u9ed8\u8ba450ms\u3002 <\/li>\n<li> purger\uff1a\u662f\u5426\u5f00\u542fpurge\u65b9\u5f0f\u79fb\u9664\u6570\u636e\u3002 <\/li>\n<li> purger_files\uff1a\u6bcf\u6b21\u79fb\u9664\u7f13\u5b58\u6587\u4ef6\u65f6\u7684\u6570\u91cf\u3002 <\/li>\n<li> purger_sleep\uff1a\u6bcf\u6b21\u79fb\u9664\u65f6\uff0c\u5141\u8bb8\u6d88\u8017\u7684\u6700\u5927\u65f6\u95f4\u3002 <\/li>\n<li> purger_threshold\uff1a\u6bcf\u6b21\u79fb\u9664\u5b8c\u6210\u540e\uff0c\u505c\u987f\u7684\u95f4\u9694\u65f6\u95f4\u3002 <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache\u300d<\/strong>\uff1a\u5f00\u542f\u6216\u5173\u95ed\u4ee3\u7406\u7f13\u5b58\uff0c\u5f00\u542f\u65f6\u9700\u8981\u6307\u5b9a\u4e00\u4e2a\u5171\u4eab\u5185\u5b58\u533a\u57df\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache&nbsp;zone&nbsp;|&nbsp;off;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">zone\u4e3a\u5185\u5b58\u533a\u57df\u7684\u540d\u79f0\uff0c\u5373\u4e0a\u9762\u4e2dkeys_zone\u8bbe\u7f6e\u7684\u540d\u79f0\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_key\u300d<\/strong>\uff1a\u5b9a\u4e49\u5982\u4f55\u751f\u6210\u7f13\u5b58\u7684\u952e\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache_key&nbsp;string;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">string\u4e3a\u751f\u6210Key\u7684\u89c4\u5219\uff0c\u5982$scheme$proxy_host$request_uri\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_valid\u300d<\/strong>\uff1a\u7f13\u5b58\u751f\u6548\u7684\u72b6\u6001\u7801\u4e0e\u8fc7\u671f\u65f6\u95f4\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache_valid&nbsp;[code&nbsp;...]&nbsp;time;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">code\u4e3a\u72b6\u6001\u7801\uff0ctime\u4e3a\u6709\u6548\u65f6\u95f4\uff0c\u53ef\u4ee5\u6839\u636e\u72b6\u6001\u7801\u8bbe\u7f6e\u4e0d\u540c\u7684\u7f13\u5b58\u65f6\u95f4\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4f8b\u5982\uff1aproxy_cache_valid 200 302 30m;<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_min_uses\u300d<\/strong>\uff1a\u8bbe\u7f6e\u8d44\u6e90\u88ab\u8bf7\u6c42\u591a\u5c11\u6b21\u540e\u88ab\u7f13\u5b58\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache_min_uses&nbsp;number;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">number\u4e3a\u6b21\u6570\uff0c\u9ed8\u8ba4\u4e3a1\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_use_stale\u300d<\/strong>\uff1a\u5f53\u540e\u7aef\u51fa\u73b0\u5f02\u5e38\u65f6\uff0c\u662f\u5426\u5141\u8bb8Nginx\u8fd4\u56de\u7f13\u5b58\u4f5c\u4e3a\u54cd\u5e94\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache_use_stale&nbsp;error;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">error\u4e3a\u9519\u8bef\u7c7b\u578b\uff0c\u53ef\u914d\u7f6etimeout|invalid_header|updating|http_500&#8230;\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_lock\u300d<\/strong>\uff1a\u5bf9\u4e8e\u76f8\u540c\u7684\u8bf7\u6c42\uff0c\u662f\u5426\u5f00\u542f\u9501\u673a\u5236\uff0c\u53ea\u5141\u8bb8\u4e00\u4e2a\u8bf7\u6c42\u53d1\u5f80\u540e\u7aef\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache_lock&nbsp;on&nbsp;|&nbsp;off;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_lock_timeout\u300d<\/strong>\uff1a\u914d\u7f6e\u9501\u8d85\u65f6\u673a\u5236\uff0c\u8d85\u51fa\u89c4\u5b9a\u65f6\u95f4\u540e\u4f1a\u91ca\u653e\u8bf7\u6c42\u3002<\/p>\n<pre>proxy_cache_lock_timeout&nbsp;time;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_methods\u300d<\/strong>\uff1a\u8bbe\u7f6e\u5bf9\u4e8e\u90a3\u4e9bHTTP\u65b9\u6cd5\u5f00\u542f\u7f13\u5b58\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache_methods&nbsp;method;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">method\u4e3a\u8bf7\u6c42\u65b9\u6cd5\u7c7b\u578b\uff0c\u5982GET\u3001HEAD\u7b49\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_no_cache\u300d<\/strong>\uff1a\u5b9a\u4e49\u4e0d\u5b58\u50a8\u7f13\u5b58\u7684\u6761\u4ef6\uff0c\u7b26\u5408\u65f6\u4e0d\u4f1a\u4fdd\u5b58\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_no_cache&nbsp;string...;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">string\u4e3a\u6761\u4ef6\uff0c\u4f8b\u5982$cookie_nocache $arg_nocache $arg_comment;<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cproxy_cache_bypass\u300d<\/strong>\uff1a\u5b9a\u4e49\u4e0d\u8bfb\u53d6\u7f13\u5b58\u7684\u6761\u4ef6\uff0c\u7b26\u5408\u65f6\u4e0d\u4f1a\u4ece\u7f13\u5b58\u4e2d\u8bfb\u53d6\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>proxy_cache_bypass&nbsp;string...;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u548c\u4e0a\u9762proxy_no_cache\u7684\u914d\u7f6e\u65b9\u6cd5\u7c7b\u4f3c\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300cadd_header\u300d<\/strong>\uff1a\u5f80\u54cd\u5e94\u5934\u4e2d\u6dfb\u52a0\u5b57\u6bb5\u4fe1\u606f\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8bed\u6cd5\uff1a<\/p>\n<pre>add_header&nbsp;fieldName&nbsp;fieldValue;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300c$upstream_cache_status\u300d<\/strong>\uff1a\u8bb0\u5f55\u4e86\u7f13\u5b58\u662f\u5426\u547d\u4e2d\u7684\u4fe1\u606f\uff0c\u5b58\u5728\u591a\u79cd\u60c5\u51b5\uff1a<\/p>\n<ul>\n<li> MISS\uff1a\u8bf7\u6c42\u672a\u547d\u4e2d\u7f13\u5b58\u3002 <\/li>\n<li> HIT\uff1a\u8bf7\u6c42\u547d\u4e2d\u7f13\u5b58\u3002 <\/li>\n<li> EXPIRED\uff1a\u8bf7\u6c42\u547d\u4e2d\u7f13\u5b58\u4f46\u7f13\u5b58\u5df2\u8fc7\u671f\u3002 <\/li>\n<li> STALE\uff1a\u8bf7\u6c42\u547d\u4e2d\u4e86\u9648\u65e7\u7f13\u5b58\u3002 <\/li>\n<li> REVALIDDATED\uff1aNginx\u9a8c\u8bc1\u9648\u65e7\u7f13\u5b58\u4f9d\u7136\u6709\u6548\u3002 <\/li>\n<li> UPDATING\uff1a\u547d\u4e2d\u7684\u7f13\u5b58\u5185\u5bb9\u9648\u65e7\uff0c\u4f46\u6b63\u5728\u66f4\u65b0\u7f13\u5b58\u3002 <\/li>\n<li> BYPASS\uff1a\u54cd\u5e94\u7ed3\u679c\u662f\u4ece\u539f\u59cb\u670d\u52a1\u5668\u83b7\u53d6\u7684\u3002 <\/li>\n<\/ul>\n<blockquote style=\"border-top: none;border-right: none;border-bottom: none;font-size: 0.9em;overflow: auto;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\">PS\uff1a\u8fd9\u4e2a\u548c\u4e4b\u524d\u7684\u4e0d\u540c\uff0c\u4e4b\u524d\u7684\u90fd\u662f\u53c2\u6570\u9879\uff0c\u8fd9\u4e2a\u662f\u4e00\u4e2aNginx\u5185\u7f6e\u53d8\u91cf\u3002<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">OK~\uff0c\u5bf9\u4e8eNginx\u4e2d\u7684\u7f13\u5b58\u914d\u7f6e\u9879\u5927\u6982\u4e86\u89e3\u540e\uff0c\u63a5\u7740\u6765\u914d\u7f6e\u4e00\u4e0bNginx\u4ee3\u7406\u7f13\u5b58\uff1a<\/p>\n<pre>http{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8bbe\u7f6e\u7f13\u5b58\u7684\u76ee\u5f55\uff0c\u5e76\u4e14\u5185\u5b58\u4e2d\u7f13\u5b58\u533a\u540d\u4e3ahot_cache\uff0c\u5927\u5c0f\u4e3a128m\uff0c&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4e09\u5929\u672a\u88ab\u8bbf\u95ee\u8fc7\u7684\u7f13\u5b58\u81ea\u52a8\u6e05\u695a\uff0c\u78c1\u76d8\u4e2d\u7f13\u5b58\u7684\u6700\u5927\u5bb9\u91cf\u4e3a2GB\u3002&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;proxy_cache_path&nbsp;\/soft\/nginx\/cache&nbsp;levels=1:2&nbsp;keys_zone=hot_cache:128m&nbsp;inactive=3d&nbsp;max_size=2g;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;server{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4f7f\u7528\u540d\u4e3anginx_cache\u7684\u7f13\u5b58\u7a7a\u95f4&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_cache&nbsp;hot_cache;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5bf9\u4e8e200\u3001206\u3001304\u3001301\u3001302\u72b6\u6001\u7801\u7684\u6570\u636e\u7f13\u5b581\u5929&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_cache_valid&nbsp;200&nbsp;206&nbsp;304&nbsp;301&nbsp;302&nbsp;1d;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5bf9\u4e8e\u5176\u4ed6\u72b6\u6001\u7684\u6570\u636e\u7f13\u5b5830\u5206\u949f&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_cache_valid&nbsp;any&nbsp;30m;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5b9a\u4e49\u751f\u6210\u7f13\u5b58\u952e\u7684\u89c4\u5219\uff08\u8bf7\u6c42\u7684url+\u53c2\u6570\u4f5c\u4e3akey\uff09&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_cache_key&nbsp;$host$uri$is_args$args;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8d44\u6e90\u81f3\u5c11\u88ab\u91cd\u590d\u8bbf\u95ee\u4e09\u6b21\u540e\u518d\u52a0\u5165\u7f13\u5b58&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_cache_min_uses&nbsp;3;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u51fa\u73b0\u91cd\u590d\u8bf7\u6c42\u65f6\uff0c\u53ea\u8ba9\u4e00\u4e2a\u53bb\u540e\u7aef\u8bfb\u6570\u636e\uff0c\u5176\u4ed6\u7684\u4ece\u7f13\u5b58\u4e2d\u8bfb\u53d6&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_cache_lock&nbsp;on;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4e0a\u9762\u7684\u9501\u8d85\u65f6\u65f6\u95f4\u4e3a3s\uff0c\u8d85\u8fc73s\u672a\u83b7\u53d6\u6570\u636e\uff0c\u5176\u4ed6\u8bf7\u6c42\u76f4\u63a5\u53bb\u540e\u7aef&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_cache_lock_timeout&nbsp;3s;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5bf9\u4e8e\u8bf7\u6c42\u53c2\u6570\u6216cookie\u4e2d\u58f0\u660e\u4e86\u4e0d\u7f13\u5b58\u7684\u6570\u636e\uff0c\u4e0d\u518d\u52a0\u5165\u7f13\u5b58&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_no_cache&nbsp;$cookie_nocache&nbsp;$arg_nocache&nbsp;$arg_comment;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5728\u54cd\u5e94\u5934\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u7f13\u5b58\u662f\u5426\u547d\u4e2d\u7684\u72b6\u6001\uff08\u4fbf\u4e8e\u8c03\u8bd5\uff09&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;Cache-status&nbsp;$upstream_cache_status;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u63a5\u7740\u6765\u770b\u4e00\u4e0b\u6548\u679c\uff0c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/32d6bb0778f2bbbf0e7b3133173b0317-10.png\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe10\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe10\" \/> <\/p>\n<p style=\"max-width:90%\">\u7b2c\u4e00\u6b21\u8bbf\u95ee\u65f6\uff0c\u56e0\u4e3a\u8fd8\u6ca1\u6709\u8bf7\u6c42\u8fc7\u8d44\u6e90\uff0c\u6240\u4ee5\u7f13\u5b58\u4e2d\u6ca1\u6709\u6570\u636e\uff0c\u56e0\u6b64\u6ca1\u6709\u547d\u4e2d\u7f13\u5b58\u3002\u7b2c\u4e8c\u3001\u4e09\u6b21\uff0c\u4f9d\u65e7\u6ca1\u6709\u547d\u4e2d\u7f13\u5b58\uff0c\u76f4\u81f3\u7b2c\u56db\u6b21\u65f6\u624d\u663e\u793a\u547d\u4e2d\uff0c\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u56e0\u4e3a\u5728\u524d\u9762\u7684\u7f13\u5b58\u914d\u7f6e\u4e2d\uff0c\u6211\u4eec\u914d\u7f6e\u4e86\u52a0\u5165\u7f13\u5b58\u7684\u6700\u4f4e\u6761\u4ef6\u4e3a\uff1a<strong>\u300c\u300c\u8d44\u6e90\u81f3\u5c11\u8981\u88ab\u8bf7\u6c42\u4e09\u6b21\u4ee5\u4e0a\u624d\u4f1a\u52a0\u5165\u7f13\u5b58\u3002\u300d\u300d<\/strong> \u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5f88\u591a\u65e0\u6548\u7f13\u5b58\u5360\u7528\u7a7a\u95f4\u3002<\/p>\n<h4> <span><\/span>\u7f13\u5b58\u6e05\u7406<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5f53\u7f13\u5b58\u8fc7\u591a\u65f6\uff0c\u5982\u679c\u4e0d\u53ca\u65f6\u6e05\u7406\u4f1a\u5bfc\u81f4\u78c1\u76d8\u7a7a\u95f4\u88ab\u201c\u5403\u5149\u201d\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u4e00\u5957\u5b8c\u5584\u7684\u7f13\u5b58\u6e05\u7406\u673a\u5236\u53bb\u5220\u9664\u7f13\u5b58\uff0c\u5728\u4e4b\u524d\u7684proxy_cache_path\u53c2\u6570\u4e2d\u6709purger\u76f8\u5173\u7684\u9009\u9879\uff0c\u5f00\u542f\u540e\u53ef\u4ee5\u5e2e\u6211\u4eec\u81ea\u52a8\u6e05\u7406\u7f13\u5b58\uff0c\u4f46\u9057\u61be\u7684\u662f\uff1a**purger\u7cfb\u5217\u53c2\u6570\u53ea\u6709\u5546\u4e1a\u7248\u7684NginxPlus\u624d\u80fd\u4f7f\u7528\uff0c\u56e0\u6b64\u9700\u8981\u4ed8\u8d39\u624d\u53ef\u4f7f\u7528\u3002**<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4e0d\u8fc7\u5929\u65e0\u7edd\u4eba\u4e4b\u8def\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5f3a\u5927\u7684\u7b2c\u4e09\u65b9\u6a21\u5757ngx_cache_purge\u6765\u66ff\u4ee3\uff0c\u5148\u6765\u5b89\u88c5\u4e00\u4e0b\u8be5\u63d2\u4ef6\uff1a\u2460\u9996\u5148\u53bb\u5230Nginx\u7684\u5b89\u88c5\u76ee\u5f55\u4e0b\uff0c\u521b\u5efa\u4e00\u4e2acache_purge\u76ee\u5f55\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;mkdir&nbsp;cache_purge&nbsp;&amp;amp;&amp;amp;&nbsp;cd&nbsp;cache_purge<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2461\u901a\u8fc7wget\u6307\u4ee4\u4ecegithub\u4e0a\u62c9\u53d6\u5b89\u88c5\u5305\u7684\u538b\u7f29\u6587\u4ef6\u5e76\u89e3\u538b\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;wget&nbsp;https:\/\/github.com\/FRiCKLE\/ngx_cache_purge\/archive\/2.3.tar.gz&nbsp;&nbsp;\n[root@localhost]#&nbsp;tar&nbsp;-xvzf&nbsp;2.3.tar.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2462\u518d\u6b21\u53bb\u5230\u4e4b\u524dNginx\u7684\u89e3\u538b\u76ee\u5f55\u4e0b\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;cd&nbsp;\/soft\/nginx\/nginx1.21.6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2463\u91cd\u65b0\u6784\u5efa\u4e00\u6b21Nginx\uff0c\u901a\u8fc7&#8211;add-module\u7684\u6307\u4ee4\u6dfb\u52a0\u521a\u521a\u7684\u7b2c\u4e09\u65b9\u6a21\u5757\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;.\/configure&nbsp;--prefix=\/soft\/nginx\/&nbsp;--add-module=\/soft\/nginx\/cache_purge\/ngx_cache_purge-2.3\/<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2464\u91cd\u65b0\u6839\u636e\u521a\u521a\u6784\u5efa\u7684Nginx\uff0c\u518d\u6b21\u7f16\u8bd1\u4e00\u4e0b\uff0c<strong>\u300c\u4f46\u5207\u8bb0\u4e0d\u8981make install\u300d<\/strong> \uff1a<\/p>\n<pre>[root@localhost]#&nbsp;make<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2465\u5220\u9664\u4e4b\u524dNginx\u7684\u542f\u52a8\u6587\u4ef6\uff0c\u4e0d\u653e\u5fc3\u7684\u4e5f\u53ef\u4ee5\u79fb\u52a8\u5230\u5176\u4ed6\u4f4d\u7f6e\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;rm&nbsp;-rf&nbsp;\/soft\/nginx\/sbin\/nginx<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2466\u4ece\u751f\u6210\u7684objs\u76ee\u5f55\u4e2d\uff0c\u91cd\u65b0\u590d\u5236\u4e00\u4e2aNginx\u7684\u542f\u52a8\u6587\u4ef6\u5230\u539f\u6765\u7684\u4f4d\u7f6e\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;cp&nbsp;objs\/nginx&nbsp;\/soft\/nginx\/sbin\/nginx<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u81f3\u6b64\uff0c\u7b2c\u4e09\u65b9\u7f13\u5b58\u6e05\u9664\u6a21\u5757ngx_cache_purge\u5c31\u5b89\u88c5\u5b8c\u6210\u4e86\uff0c\u63a5\u4e0b\u6765\u7a0d\u5fae\u4fee\u6539\u4e00\u4e0bnginx.conf\u914d\u7f6e\uff0c\u518d\u6dfb\u52a0\u4e00\u6761location\u89c4\u5219\uff1a<\/p>\n<pre>location&nbsp;~&nbsp;\/purge(\/.*)&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;#&nbsp;\u914d\u7f6e\u53ef\u4ee5\u6267\u884c\u6e05\u9664\u64cd\u4f5c\u7684IP\uff08\u7ebf\u4e0a\u53ef\u4ee5\u914d\u7f6e\u6210\u5185\u7f51\u673a\u5668\uff09&nbsp;&nbsp;\n&nbsp;&nbsp;#&nbsp;allow&nbsp;127.0.0.1;&nbsp;#&nbsp;\u4ee3\u8868\u672c\u673a&nbsp;&nbsp;\n&nbsp;&nbsp;allow&nbsp;all;&nbsp;#&nbsp;\u4ee3\u8868\u5141\u8bb8\u4efb\u610fIP\u6e05\u9664\u7f13\u5b58&nbsp;&nbsp;\n&nbsp;&nbsp;proxy_cache_purge&nbsp;$host$1$is_args$args;&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7136\u540e\u518d\u91cd\u542fNginx\uff0c\u63a5\u4e0b\u6765\u5373\u53ef\u901a\u8fc7http:\/\/xxx\/purge\/xx\u7684\u65b9\u5f0f\u6e05\u9664\u7f13\u5b58\u3002<\/p>\n<h3> <span><\/span>\u516b\u3001Nginx\u5b9e\u73b0IP\u9ed1\u767d\u540d\u5355<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6709\u65f6\u5019\u5f80\u5f80\u6709\u4e9b\u9700\u6c42\uff0c\u53ef\u80fd\u67d0\u4e9b\u63a5\u53e3\u53ea\u80fd\u5f00\u653e\u7ed9\u5bf9\u5e94\u7684\u5408\u4f5c\u5546\uff0c\u6216\u8005\u8d2d\u4e70\/\u63a5\u5165API\u7684\u5408\u4f5c\u4f19\u4f34\uff0c\u90a3\u4e48\u6b64\u65f6\u5c31\u9700\u8981\u5b9e\u73b0\u7c7b\u4f3c\u4e8eIP\u767d\u540d\u5355\u7684\u529f\u80fd\u3002\u800c\u6709\u65f6\u5019\u6709\u4e9b\u6076\u610f\u653b\u51fb\u8005\u6216\u722c\u866b\u7a0b\u5e8f\uff0c\u88ab\u8bc6\u522b\u540e\u9700\u8981\u7981\u6b62\u5176\u518d\u6b21\u8bbf\u95ee\u7f51\u7ad9\uff0c\u56e0\u6b64\u4e5f\u9700\u8981\u5b9e\u73b0IP\u9ed1\u540d\u5355\u3002\u90a3\u4e48\u8fd9\u4e9b\u529f\u80fd\u65e0\u9700\u4ea4\u7531\u540e\u7aef\u5b9e\u73b0\uff0c\u53ef\u76f4\u63a5\u5728Nginx\u4e2d\u5904\u7406\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">Nginx\u505a\u9ed1\u767d\u540d\u5355\u673a\u5236\uff0c\u4e3b\u8981\u662f\u901a\u8fc7allow\u3001deny\u914d\u7f6e\u9879\u6765\u5b9e\u73b0\uff1a<\/p>\n<pre>allow&nbsp;xxx.xxx.xxx.xxx;&nbsp;#&nbsp;\u5141\u8bb8\u6307\u5b9a\u7684IP\u8bbf\u95ee\uff0c\u53ef\u4ee5\u7528\u4e8e\u5b9e\u73b0\u767d\u540d\u5355\u3002&nbsp;&nbsp;\ndeny&nbsp;xxx.xxx.xxx.xxx;&nbsp;#&nbsp;\u7981\u6b62\u6307\u5b9a\u7684IP\u8bbf\u95ee\uff0c\u53ef\u4ee5\u7528\u4e8e\u5b9e\u73b0\u9ed1\u540d\u5355\u3002<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8981\u540c\u65f6\u5c4f\u853d\/\u5f00\u653e\u591a\u4e2aIP\u8bbf\u95ee\u65f6\uff0c\u5982\u679c\u6240\u6709IP\u5168\u90e8\u5199\u5728nginx.conf\u6587\u4ef6\u4e2d\u5b9a\u7136\u662f\u4e0d\u663e\u793a\u7684\uff0c\u8fd9\u79cd\u65b9\u5f0f\u6bd4\u8f83\u5197\u4f59\uff0c\u90a3\u4e48\u53ef\u4ee5\u65b0\u5efa\u4e24\u4e2a\u6587\u4ef6BlocksIP.conf\u3001WhiteIP.conf\uff1a<\/p>\n<pre>#&nbsp;--------\u9ed1\u540d\u5355\uff1aBlocksIP.conf---------&nbsp;&nbsp;\ndeny&nbsp;192.177.12.222;&nbsp;#&nbsp;\u5c4f\u853d192.177.12.222\u8bbf\u95ee&nbsp;&nbsp;\ndeny&nbsp;192.177.44.201;&nbsp;#&nbsp;\u5c4f\u853d192.177.44.201\u8bbf\u95ee&nbsp;&nbsp;\ndeny&nbsp;127.0.0.0\/8;&nbsp;#&nbsp;\u5c4f\u853d127.0.0.1\u5230127.255.255.254\u7f51\u6bb5\u4e2d\u7684\u6240\u6709IP\u8bbf\u95ee&nbsp;&nbsp;\n&nbsp;&nbsp;\n#&nbsp;--------\u767d\u540d\u5355\uff1aWhiteIP.conf---------&nbsp;&nbsp;\nallow&nbsp;192.177.12.222;&nbsp;#&nbsp;\u5141\u8bb8192.177.12.222\u8bbf\u95ee&nbsp;&nbsp;\nallow&nbsp;192.177.44.201;&nbsp;#&nbsp;\u5141\u8bb8192.177.44.201\u8bbf\u95ee&nbsp;&nbsp;\nallow&nbsp;127.45.0.0\/16;&nbsp;#&nbsp;\u5141\u8bb8127.45.0.1\u5230127.45.255.254\u7f51\u6bb5\u4e2d\u7684\u6240\u6709IP\u8bbf\u95ee&nbsp;&nbsp;\ndeny&nbsp;all;&nbsp;#&nbsp;\u9664\u5f00\u4e0a\u8ff0IP\u5916\uff0c\u5176\u4ed6IP\u5168\u90e8\u7981\u6b62\u8bbf\u95ee<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5206\u522b\u5c06\u8981\u7981\u6b62\/\u5f00\u653e\u7684IP\u6dfb\u52a0\u5230\u5bf9\u5e94\u7684\u6587\u4ef6\u540e\uff0c\u53ef\u4ee5\u518d\u5c06\u8fd9\u4e24\u4e2a\u6587\u4ef6\u5728nginx.conf\u4e2d\u5bfc\u5165\uff1a<\/p>\n<pre>http{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5c4f\u853d\u8be5\u6587\u4ef6\u4e2d\u7684\u6240\u6709IP&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;include&nbsp;\/soft\/nginx\/IP\/BlocksIP.conf;&nbsp;&nbsp;&nbsp;\n&nbsp;server{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;xxx&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u67d0\u4e00\u7cfb\u5217\u63a5\u53e3\u53ea\u5f00\u653e\u7ed9\u767d\u540d\u5355\u4e2d\u7684IP&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include&nbsp;\/soft\/nginx\/IP\/blockip.conf;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;}&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5bf9\u4e8e\u6587\u4ef6\u5177\u4f53\u5728\u54ea\u513f\u5bfc\u5165\uff0c\u8fd9\u4e2a\u4e5f\u5e76\u975e\u968f\u610f\u7684\uff0c\u5982\u679c\u8981\u6574\u7ad9\u5c4f\u853d\/\u5f00\u653e\u5c31\u5728http\u4e2d\u5bfc\u5165\uff0c\u5982\u679c\u53ea\u9700\u8981\u4e00\u4e2a\u57df\u540d\u4e0b\u5c4f\u853d\/\u5f00\u653e\u5c31\u5728sever\u4e2d\u5bfc\u5165\uff0c\u5982\u679c\u53ea\u9700\u8981\u9488\u5bf9\u4e8e\u67d0\u4e00\u7cfb\u5217\u63a5\u53e3\u5c4f\u853d\/\u5f00\u653eIP\uff0c\u90a3\u4e48\u5c31\u5728location\u4e2d\u5bfc\u5165\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5f53\u7136\uff0c\u4e0a\u8ff0\u53ea\u662f\u6700\u7b80\u5355\u7684IP\u9ed1\/\u767d\u540d\u5355\u5b9e\u73b0\u65b9\u5f0f\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u901a\u8fc7ngx_http_geo_module\u3001ngx_http_geo_module\u7b2c\u4e09\u65b9\u5e93\u53bb\u5b9e\u73b0\uff08\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u6309\u5730\u533a\u3001\u56fd\u5bb6\u8fdb\u884c\u5c4f\u853d\uff0c\u5e76\u4e14\u63d0\u4f9b\u4e86IP\u5e93\uff09\u3002<\/p>\n<h3> <span><\/span>\u4e5d\u3001Nginx\u8de8\u57df\u914d\u7f6e<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8de8\u57df\u95ee\u9898\u5728\u4e4b\u524d\u7684\u5355\u4f53\u67b6\u6784\u5f00\u53d1\u4e2d\uff0c\u5176\u5b9e\u662f\u6bd4\u8f83\u5c11\u89c1\u7684\u95ee\u9898\uff0c\u9664\u975e\u662f\u9700\u8981\u63a5\u5165\u7b2c\u4e09\u65b9SDK\u65f6\uff0c\u624d\u9700\u8981\u5904\u7406\u6b64\u95ee\u9898\u3002\u4f46\u968f\u7740\u73b0\u5728\u524d\u540e\u7aef\u5206\u79bb\u3001\u5206\u5e03\u5f0f\u67b6\u6784\u7684\u6d41\u884c\uff0c\u8de8\u57df\u95ee\u9898\u4e5f\u6210\u4e3a\u4e86\u6bcf\u4e2aJava\u5f00\u53d1\u5fc5\u987b\u8981\u61c2\u5f97\u89e3\u51b3\u7684\u4e00\u4e2a\u95ee\u9898\u3002<\/p>\n<h4> <span><\/span>\u8de8\u57df\u95ee\u9898\u4ea7\u751f\u7684\u539f\u56e0<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4ea7\u751f\u8de8\u57df\u95ee\u9898\u7684\u4e3b\u8981\u539f\u56e0\u5c31\u5728\u4e8e <strong>\u300c\u540c\u6e90\u7b56\u7565\u300d<\/strong> \uff0c\u4e3a\u4e86\u4fdd\u8bc1\u7528\u6237\u4fe1\u606f\u5b89\u5168\uff0c\u9632\u6b62\u6076\u610f\u7f51\u7ad9\u7a83\u53d6\u6570\u636e\uff0c\u540c\u6e90\u7b56\u7565\u662f\u5fc5\u987b\u7684\uff0c\u5426\u5219cookie\u53ef\u4ee5\u5171\u4eab\u3002\u7531\u4e8ehttp\u65e0\u72b6\u6001\u534f\u8bae\u901a\u5e38\u4f1a\u501f\u52a9cookie\u6765\u5b9e\u73b0\u6709\u72b6\u6001\u7684\u4fe1\u606f\u8bb0\u5f55\uff0c\u4f8b\u5982\u7528\u6237\u7684\u8eab\u4efd\/\u5bc6\u7801\u7b49\uff0c\u56e0\u6b64\u4e00\u65e6cookie\u88ab\u5171\u4eab\uff0c\u90a3\u4e48\u4f1a\u5bfc\u81f4\u7528\u6237\u7684\u8eab\u4efd\u4fe1\u606f\u88ab\u76d7\u53d6\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u540c\u6e90\u7b56\u7565\u4e3b\u8981\u662f\u6307\u4e09\u70b9\u76f8\u540c\uff0c<strong>\u300c\u300c\u534f\u8bae+\u57df\u540d+\u7aef\u53e3\u300d\u300d<\/strong> \u76f8\u540c\u7684\u4e24\u4e2a\u8bf7\u6c42\uff0c\u5219\u53ef\u4ee5\u88ab\u770b\u505a\u662f\u540c\u6e90\u7684\uff0c\u4f46\u5982\u679c\u5176\u4e2d\u4efb\u610f\u4e00\u70b9\u5b58\u5728\u4e0d\u540c\uff0c\u5219\u4ee3\u8868\u662f\u4e24\u4e2a\u4e0d\u540c\u6e90\u7684\u8bf7\u6c42\uff0c\u540c\u6e90\u7b56\u7565\u4f1a\u9650\u5236\u4e86\u4e0d\u540c\u6e90\u4e4b\u95f4\u7684\u8d44\u6e90\u4ea4\u4e92\u3002<\/p>\n<h4> <span><\/span>Nginx\u89e3\u51b3\u8de8\u57df\u95ee\u9898<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5f04\u660e\u767d\u4e86\u8de8\u57df\u95ee\u9898\u7684\u4ea7\u751f\u539f\u56e0\uff0c\u63a5\u4e0b\u6765\u770b\u770bNginx\u4e2d\u53c8\u8be5\u5982\u4f55\u89e3\u51b3\u8de8\u57df\u5462\uff1f\u5176\u5b9e\u6bd4\u8f83\u7b80\u5355\uff0c\u5728nginx.conf\u4e2d\u7a0d\u5fae\u6dfb\u52a0\u4e00\u70b9\u914d\u7f6e\u5373\u53ef\uff1a<\/p>\n<pre>location&nbsp;\/&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5141\u8bb8\u8de8\u57df\u7684\u8bf7\u6c42\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u53d8\u91cf$http_origin\uff0c*\u8868\u793a\u6240\u6709&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;'Access-Control-Allow-Origin'&nbsp;*;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5141\u8bb8\u643a\u5e26cookie\u8bf7\u6c42&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;'Access-Control-Allow-Credentials'&nbsp;'true';&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5141\u8bb8\u8de8\u57df\u8bf7\u6c42\u7684\u65b9\u6cd5\uff1aGET,POST,OPTIONS,PUT&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;'Access-Control-Allow-Methods'&nbsp;'GET,POST,OPTIONS,PUT';&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5141\u8bb8\u8bf7\u6c42\u65f6\u643a\u5e26\u7684\u5934\u90e8\u4fe1\u606f\uff0c*\u8868\u793a\u6240\u6709&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;'Access-Control-Allow-Headers'&nbsp;*;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5141\u8bb8\u53d1\u9001\u6309\u6bb5\u83b7\u53d6\u8d44\u6e90\u7684\u8bf7\u6c42&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;'Access-Control-Expose-Headers'&nbsp;'Content-Length,Content-Range';&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4e00\u5b9a\u8981\u6709\uff01\uff01\uff01\u5426\u5219Post\u8bf7\u6c42\u65e0\u6cd5\u8fdb\u884c\u8de8\u57df\uff01&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5728\u53d1\u9001Post\u8de8\u57df\u8bf7\u6c42\u524d\uff0c\u4f1a\u4ee5Options\u65b9\u5f0f\u53d1\u9001\u9884\u68c0\u8bf7\u6c42\uff0c\u670d\u52a1\u5668\u63a5\u53d7\u65f6\u624d\u4f1a\u6b63\u5f0f\u8bf7\u6c42&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($request_method&nbsp;=&nbsp;'OPTIONS')&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;'Access-Control-Max-Age'&nbsp;1728000;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;'Content-Type'&nbsp;'text\/plain;&nbsp;charset=utf-8';&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_header&nbsp;'Content-Length'&nbsp;0;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5bf9\u4e8eOptions\u65b9\u5f0f\u7684\u8bf7\u6c42\u8fd4\u56de204\uff0c\u8868\u793a\u63a5\u53d7\u8de8\u57df\u8bf7\u6c42&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;204;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728nginx.conf\u6587\u4ef6\u52a0\u4e0a\u5982\u4e0a\u914d\u7f6e\u540e\uff0c\u8de8\u57df\u8bf7\u6c42\u5373\u53ef\u751f\u6548\u4e86\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4f46\u5982\u679c\u540e\u7aef\u662f\u91c7\u7528\u5206\u5e03\u5f0f\u67b6\u6784\u5f00\u53d1\u7684\uff0c\u6709\u65f6\u5019RPC\u8c03\u7528\u4e5f\u9700\u8981\u89e3\u51b3\u8de8\u57df\u95ee\u9898\uff0c\u4e0d\u7136\u4e5f\u540c\u6837\u4f1a\u51fa\u73b0\u65e0\u6cd5\u8de8\u57df\u8bf7\u6c42\u7684\u5f02\u5e38\uff0c\u56e0\u6b64\u53ef\u4ee5\u5728\u4f60\u7684\u540e\u7aef\u9879\u76ee\u4e2d\uff0c\u901a\u8fc7\u7ee7\u627fHandlerInterceptorAdapter\u7c7b\u3001\u5b9e\u73b0WebMvcConfigurer\u63a5\u53e3\u3001\u6dfb\u52a0@CrossOrgin\u6ce8\u89e3\u7684\u65b9\u5f0f\u5b9e\u73b0\u63a5\u53e3\u4e4b\u95f4\u7684\u8de8\u57df\u914d\u7f6e\u3002<\/p>\n<h3> <span><\/span>\u5341\u3001Nginx\u9632\u76d7\u94fe\u8bbe\u8ba1<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u9996\u5148\u4e86\u89e3\u4e00\u4e0b\u4f55\u8c13\u76d7\u94fe\uff1a<strong>\u300c\u300c\u76d7\u94fe\u5373\u662f\u6307\u5916\u90e8\u7f51\u7ad9\u5f15\u5165\u5f53\u524d\u7f51\u7ad9\u7684\u8d44\u6e90\u5bf9\u5916\u5c55\u793a\u300d\u300d<\/strong> \uff0c\u6765\u4e3e\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u7406\u89e3\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u597d\u6bd4\u58c1\u7eb8\u7f51\u7ad9X\u7ad9\u3001Y\u7ad9\uff0cX\u7ad9\u662f\u4e00\u70b9\u70b9\u53bb\u8d2d\u4e70\u7248\u6743\u3001\u7b7e\u7ea6\u4f5c\u8005\u7684\u65b9\u5f0f\uff0c\u4ece\u800c\u79ef\u7d2f\u4e86\u6d77\u91cf\u7684\u58c1\u7eb8\u7d20\u6750\uff0c\u4f46Y\u7ad9\u7531\u4e8e\u8d44\u91d1\u7b49\u5404\u65b9\u9762\u7684\u539f\u56e0\uff0c\u5c31\u76f4\u63a5\u901a\u8fc7<img decoding=\"async\" src=\"https:\/\/www.php.cn\/faq\/X%E7%AB%99\/xxx.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe11\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe11\" \/>\u8fd9\u79cd\u65b9\u5f0f\u7167\u642c\u4e86X\u7ad9\u7684\u6240\u6709\u58c1\u7eb8\u8d44\u6e90\uff0c\u7ee7\u800c\u63d0\u4f9b\u7ed9\u7528\u6237\u4e0b\u8f7d\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u90a3\u4e48\u5982\u679c\u6211\u4eec\u81ea\u5df1\u662f\u8fd9\u4e2aX\u7ad9\u7684Boss\uff0c\u5fc3\u4e2d\u5fc5\u7136\u4e0d\u723d\uff0c\u90a3\u4e48\u6b64\u65f6\u53c8\u8be5\u5982\u4f55\u5c4f\u853d\u8fd9\u7c7b\u95ee\u9898\u5462\uff1f\u90a3\u4e48\u63a5\u4e0b\u6765\u8981\u53d9\u8bf4\u7684<strong>\u300c\u300c\u9632\u76d7\u94fe\u300d\u300d<\/strong> \u767b\u573a\u4e86\uff01<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">Nginx\u7684\u9632\u76d7\u94fe\u673a\u5236\u5b9e\u73b0\uff0c\u8ddf\u4e00\u4e2a\u5934\u90e8\u5b57\u6bb5\uff1aReferer\u6709\u5173\uff0c\u8be5\u5b57\u6bb5\u4e3b\u8981\u63cf\u8ff0\u4e86\u5f53\u524d\u8bf7\u6c42\u662f\u4ece\u54ea\u513f\u53d1\u51fa\u7684\uff0c\u90a3\u4e48\u5728Nginx\u4e2d\u5c31\u53ef\u83b7\u53d6\u8be5\u503c\uff0c\u7136\u540e\u5224\u65ad\u662f\u5426\u4e3a\u672c\u7ad9\u7684\u8d44\u6e90\u5f15\u7528\u8bf7\u6c42\uff0c\u5982\u679c\u4e0d\u662f\u5219\u4e0d\u5141\u8bb8\u8bbf\u95ee\u3002Nginx\u4e2d\u5b58\u5728\u4e00\u4e2a\u914d\u7f6e\u9879\u4e3avalid_referers\uff0c\u6b63\u597d\u53ef\u4ee5\u6ee1\u8db3\u524d\u9762\u7684\u9700\u6c42\uff0c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>valid_referers&nbsp;none&nbsp;|&nbsp;blocked&nbsp;|&nbsp;server_names&nbsp;|&nbsp;string&nbsp;...;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> none\uff1a\u8868\u793a\u63a5\u53d7\u6ca1\u6709Referer\u5b57\u6bb5\u7684HTTP\u8bf7\u6c42\u8bbf\u95ee\u3002 <\/li>\n<li> blocked\uff1a\u8868\u793a\u5141\u8bb8http:\/\/\u6216https\/\/\u4ee5\u5916\u7684\u8bf7\u6c42\u8bbf\u95ee\u3002 <\/li>\n<li> server_names\uff1a\u8d44\u6e90\u7684\u767d\u540d\u5355\uff0c\u8fd9\u91cc\u53ef\u4ee5\u6307\u5b9a\u5141\u8bb8\u8bbf\u95ee\u7684\u57df\u540d\u3002 <\/li>\n<li> string\uff1a\u53ef\u81ea\u5b9a\u4e49\u5b57\u7b26\u4e32\uff0c\u652f\u914d\u901a\u914d\u7b26\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u5199\u6cd5\u3002 <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7b80\u5355\u4e86\u89e3\u8bed\u6cd5\u540e\uff0c\u63a5\u4e0b\u6765\u7684\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n<pre>#&nbsp;\u5728\u52a8\u9759\u5206\u79bb\u7684location\u4e2d\u5f00\u542f\u9632\u76d7\u94fe\u673a\u5236&nbsp;&nbsp;\nlocation&nbsp;~&nbsp;.*.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css){&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6700\u540e\u9762\u7684\u503c\u5728\u4e0a\u7ebf\u524d\u53ef\u914d\u7f6e\u4e3a\u5141\u8bb8\u7684\u57df\u540d\u5730\u5740&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;valid_referers&nbsp;blocked&nbsp;192.168.12.129;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($invalid_referer)&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u53ef\u4ee5\u914d\u7f6e\u6210\u8fd4\u56de\u4e00\u5f20\u7981\u6b62\u76d7\u53d6\u7684\u56fe\u7247&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;rewrite&nbsp;&nbsp;&nbsp;^\/&nbsp;http:\/\/xx.xx.com\/NO.jpg;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4e5f\u53ef\u76f4\u63a5\u8fd4\u56de403&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;&nbsp;&nbsp;403;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;\/soft\/nginx\/static_resources;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;expires&nbsp;7d;&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6839\u636e\u4e0a\u8ff0\u4e2d\u7684\u5185\u5bb9\u914d\u7f6e\u540e\uff0c\u5c31\u5df2\u7ecf\u901a\u8fc7Nginx\u5b9e\u73b0\u4e86\u6700\u57fa\u672c\u7684\u9632\u76d7\u94fe\u673a\u5236\uff0c\u6700\u540e\u53ea\u9700\u8981\u989d\u5916\u91cd\u542f\u4e00\u4e0b\u5c31\u597d\u5566\uff01\u5f53\u7136\uff0c\u5bf9\u4e8e\u9632\u76d7\u94fe\u673a\u5236\u5b9e\u73b0\u8fd9\u5757\uff0c\u4e5f\u6709\u4e13\u95e8\u7684\u7b2c\u4e09\u65b9\u6a21\u5757ngx_http_accesskey_module\u5b9e\u73b0\u4e86\u66f4\u4e3a\u5b8c\u5584\u7684\u8bbe\u8ba1\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u81ea\u884c\u53bb\u770b\u770b\u3002<\/p>\n<blockquote style=\"border-top: none;border-right: none;border-bottom: none;font-size: 0.9em;overflow: auto;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\">PS\uff1a\u9632\u76d7\u94fe\u673a\u5236\u4e5f\u65e0\u6cd5\u89e3\u51b3\u722c\u866b\u4f2a\u9020referers\u4fe1\u606f\u7684\u8fd9\u79cd\u65b9\u5f0f\u6293\u53d6\u6570\u636e\u3002<\/p>\n<\/blockquote>\n<h3> <span><\/span>\u5341\u4e00\u3001Nginx\u5927\u6587\u4ef6\u4f20\u8f93\u914d\u7f6e<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728\u67d0\u4e9b\u4e1a\u52a1\u573a\u666f\u4e2d\u9700\u8981\u4f20\u8f93\u4e00\u4e9b\u5927\u6587\u4ef6\uff0c\u4f46\u5927\u6587\u4ef6\u4f20\u8f93\u65f6\u5f80\u5f80\u90fd\u4f1a\u4f1a\u51fa\u73b0\u4e00\u4e9bBug\uff0c\u6bd4\u5982\u6587\u4ef6\u8d85\u51fa\u9650\u5236\u3001\u6587\u4ef6\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u8bf7\u6c42\u8d85\u65f6\u7b49\uff0c\u90a3\u4e48\u6b64\u65f6\u5c31\u53ef\u4ee5\u5728Nginx\u7a0d\u5fae\u505a\u4e00\u4e9b\u914d\u7f6e\uff0c\u5148\u6765\u4e86\u89e3\u4e00\u4e9b\u5173\u4e8e\u5927\u6587\u4ef6\u4f20\u8f93\u65f6\u53ef\u80fd\u4f1a\u7528\u7684\u914d\u7f6e\u9879\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/e5a8f9763674d456214d666800218afc-11.png\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe12\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe12\" \/> <\/p>\n<p style=\"max-width:90%\">\u5728\u4f20\u8f93\u5927\u6587\u4ef6\u65f6\uff0cclient_max_body_size\u3001client_header_timeout\u3001proxy_read_timeout\u3001proxy_send_timeout\u8fd9\u56db\u4e2a\u53c2\u6570\u503c\u90fd\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u9879\u76ee\u7684\u5b9e\u9645\u60c5\u51b5\u6765\u914d\u7f6e\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4e0a\u8ff0\u914d\u7f6e\u4ec5\u662f\u4f5c\u4e3a\u4ee3\u7406\u5c42\u9700\u8981\u914d\u7f6e\u7684\uff0c\u56e0\u4e3a\u6700\u7ec8\u5ba2\u6237\u7aef\u4f20\u8f93\u6587\u4ef6\u8fd8\u662f\u76f4\u63a5\u4e0e\u540e\u7aef\u8fdb\u884c\u4ea4\u4e92\uff0c\u8fd9\u91cc\u53ea\u662f\u628a\u4f5c\u4e3a\u7f51\u5173\u5c42\u7684Nginx\u914d\u7f6e\u8c03\u9ad8\u4e00\u70b9\uff0c\u8c03\u5230\u80fd\u591f\u201c\u5bb9\u7eb3\u5927\u6587\u4ef6\u201d\u4f20\u8f93\u7684\u7a0b\u5ea6\u3002\u5f53\u7136\uff0cNginx\u4e2d\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u6587\u4ef6\u670d\u52a1\u5668\u4f7f\u7528\uff0c\u4f46\u9700\u8981\u7528\u5230\u4e00\u4e2a\u4e13\u95e8\u7684\u7b2c\u4e09\u65b9\u6a21\u5757nginx-upload-module\uff0c\u5982\u679c\u9879\u76ee\u4e2d\u6587\u4ef6\u4e0a\u4f20\u7684\u4f5c\u7528\u5904\u4e0d\u591a\uff0c\u90a3\u4e48\u5efa\u8bae\u53ef\u4ee5\u901a\u8fc7Nginx\u642d\u5efa\uff0c\u6bd5\u7adf\u53ef\u4ee5\u8282\u7701\u4e00\u53f0\u6587\u4ef6\u670d\u52a1\u5668\u8d44\u6e90\u3002\u4f46\u5982\u82e5\u6587\u4ef6\u4e0a\u4f20\/\u4e0b\u8f7d\u8f83\u4e3a\u9891\u7e41\uff0c\u90a3\u4e48\u8fd8\u662f\u5efa\u8bae\u989d\u5916\u642d\u5efa\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5e76\u5c06\u4e0a\u4f20\/\u4e0b\u8f7d\u529f\u80fd\u4ea4\u7531\u540e\u7aef\u5904\u7406\u3002<\/p>\n<h3> <span><\/span>\u5341\u4e8c\u3001Nginx\u914d\u7f6eSLL\u8bc1\u4e66<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u968f\u7740\u8d8a\u6765\u8d8a\u591a\u7684\u7f51\u7ad9\u63a5\u5165HTTPS\uff0c\u56e0\u6b64Nginx\u4e2d\u4ec5\u914d\u7f6eHTTP\u8fd8\u4e0d\u591f\uff0c\u5f80\u5f80\u8fd8\u9700\u8981\u76d1\u542c443\u7aef\u53e3\u7684\u8bf7\u6c42\uff0cHTTPS\u4e3a\u4e86\u786e\u4fdd\u901a\u4fe1\u5b89\u5168\uff0c\u6240\u4ee5\u670d\u52a1\u7aef\u9700\u914d\u7f6e\u5bf9\u5e94\u7684\u6570\u5b57\u8bc1\u4e66\uff0c\u5f53\u9879\u76ee\u4f7f\u7528Nginx\u4f5c\u4e3a\u7f51\u5173\u65f6\uff0c\u90a3\u4e48\u8bc1\u4e66\u5728Nginx\u4e2d\u4e5f\u9700\u8981\u914d\u7f6e\uff0c\u63a5\u4e0b\u6765\u7b80\u5355\u804a\u4e00\u4e0b\u5173\u4e8eSSL\u8bc1\u4e66\u914d\u7f6e\u8fc7\u7a0b\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2460\u5148\u53bbCA\u673a\u6784\u6216\u4ece\u4e91\u63a7\u5236\u53f0\u4e2d\u7533\u8bf7\u5bf9\u5e94\u7684SSL\u8bc1\u4e66\uff0c\u5ba1\u6838\u901a\u8fc7\u540e\u4e0b\u8f7dNginx\u7248\u672c\u7684\u8bc1\u4e66\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2461\u4e0b\u8f7d\u6570\u5b57\u8bc1\u4e66\u540e\uff0c\u5b8c\u6574\u7684\u6587\u4ef6\u603b\u5171\u6709\u4e09\u4e2a\uff1a.crt\u3001.key\u3001.pem\uff1a<\/p>\n<ul>\n<li> .crt\uff1a\u6570\u5b57\u8bc1\u4e66\u6587\u4ef6\uff0c.crt\u662f.pem\u7684\u62d3\u5c55\u6587\u4ef6\uff0c\u56e0\u6b64\u6709\u4e9b\u4eba\u4e0b\u8f7d\u540e\u53ef\u80fd\u6ca1\u6709\u3002 <\/li>\n<li> .key\uff1a\u670d\u52a1\u5668\u7684\u79c1\u94a5\u6587\u4ef6\uff0c\u53ca\u975e\u5bf9\u79f0\u52a0\u5bc6\u7684\u79c1\u94a5\uff0c\u7528\u4e8e\u89e3\u5bc6\u516c\u94a5\u4f20\u8f93\u7684\u6570\u636e\u3002 <\/li>\n<li> .pem\uff1aBase64-encoded\u7f16\u7801\u683c\u5f0f\u7684\u6e90\u8bc1\u4e66\u6587\u672c\u6587\u4ef6\uff0c\u53ef\u81ea\u884c\u6839\u9700\u6c42\u4fee\u6539\u62d3\u5c55\u540d\u3002 <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2462\u5728Nginx\u76ee\u5f55\u4e0b\u65b0\u5efacertificate\u76ee\u5f55\uff0c\u5e76\u5c06\u4e0b\u8f7d\u597d\u7684\u8bc1\u4e66\/\u79c1\u94a5\u7b49\u6587\u4ef6\u4e0a\u4f20\u81f3\u8be5\u76ee\u5f55\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2463\u6700\u540e\u4fee\u6539\u4e00\u4e0bnginx.conf\u6587\u4ef6\u5373\u53ef\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>#&nbsp;----------HTTPS\u914d\u7f6e-----------&nbsp;&nbsp;\nserver&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u76d1\u542cHTTPS\u9ed8\u8ba4\u7684443\u7aef\u53e3&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;443;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u914d\u7f6e\u81ea\u5df1\u9879\u76ee\u7684\u57df\u540d&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;www.xxx.com;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6253\u5f00SSL\u52a0\u5bc6\u4f20\u8f93&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;ssl&nbsp;on;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8f93\u5165\u57df\u540d\u540e\uff0c\u9996\u9875\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;html;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u914d\u7f6e\u9996\u9875\u7684\u6587\u4ef6\u540d&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;index.html&nbsp;index.htm&nbsp;index.jsp&nbsp;index.ftl;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u914d\u7f6e\u81ea\u5df1\u4e0b\u8f7d\u7684\u6570\u5b57\u8bc1\u4e66&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;ssl_certificate&nbsp;&nbsp;certificate\/xxx.pem;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u914d\u7f6e\u81ea\u5df1\u4e0b\u8f7d\u7684\u670d\u52a1\u5668\u79c1\u94a5&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;ssl_certificate_key&nbsp;certificate\/xxx.key;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u505c\u6b62\u901a\u4fe1\u65f6\uff0c\u52a0\u5bc6\u4f1a\u8bdd\u7684\u6709\u6548\u671f\uff0c\u5728\u8be5\u65f6\u95f4\u6bb5\u5185\u4e0d\u9700\u8981\u91cd\u65b0\u4ea4\u6362\u5bc6\u94a5&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;ssl_session_timeout&nbsp;5m;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;TLS\u63e1\u624b\u65f6\uff0c\u670d\u52a1\u5668\u91c7\u7528\u7684\u5bc6\u7801\u5957\u4ef6&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;ssl_ciphers&nbsp;ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u670d\u52a1\u5668\u652f\u6301\u7684TLS\u7248\u672c&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;ssl_protocols&nbsp;TLSv1&nbsp;TLSv1.1&nbsp;TLSv1.2;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5f00\u542f\u7531\u670d\u52a1\u5668\u51b3\u5b9a\u91c7\u7528\u7684\u5bc6\u7801\u5957\u4ef6&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;ssl_prefer_server_ciphers&nbsp;on;&nbsp;&nbsp;\n&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;....&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n}&nbsp;&nbsp;\n&nbsp;&nbsp;\n#&nbsp;---------HTTP\u8bf7\u6c42\u8f6cHTTPS-------------&nbsp;&nbsp;\nserver&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u76d1\u542cHTTP\u9ed8\u8ba4\u768480\u7aef\u53e3&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;80;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5982\u679c80\u7aef\u53e3\u51fa\u73b0\u8bbf\u95ee\u8be5\u57df\u540d\u7684\u8bf7\u6c42&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;www.xxx.com;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5c06\u8bf7\u6c42\u6539\u5199\u4e3aHTTPS\uff08\u8fd9\u91cc\u5199\u4f60\u914d\u7f6e\u4e86HTTPS\u7684\u57df\u540d\uff09&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;rewrite&nbsp;^(.*)$&nbsp;https:\/\/www.xxx.com;&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">OK~\uff0c\u6839\u636e\u5982\u4e0a\u914d\u7f6e\u4e86Nginx\u540e\uff0c\u4f60\u7684\u7f51\u7ad9\u5373\u53ef\u901a\u8fc7https:\/\/\u7684\u65b9\u5f0f\u8bbf\u95ee\uff0c\u5e76\u4e14\u5f53\u5ba2\u6237\u7aef\u4f7f\u7528http:\/\/\u7684\u65b9\u5f0f\u8bbf\u95ee\u65f6\uff0c\u4f1a\u81ea\u52a8\u5c06\u5176\u6539\u5199\u4e3aHTTPS\u8bf7\u6c42\u3002<\/p>\n<h3> <span><\/span>\u5341\u4e09\u3001Nginx\u7684\u9ad8\u53ef\u7528<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7ebf\u4e0a\u5982\u679c\u91c7\u7528\u5355\u4e2a\u8282\u70b9\u7684\u65b9\u5f0f\u90e8\u7f72Nginx\uff0c\u96be\u514d\u4f1a\u51fa\u73b0\u5929\u707e\u4eba\u7978\uff0c\u6bd4\u5982\u7cfb\u7edf\u5f02\u5e38\u3001\u7a0b\u5e8f\u5b95\u673a\u3001\u670d\u52a1\u5668\u65ad\u7535\u3001\u673a\u623f\u7206\u70b8\u3001\u5730\u7403\u6bc1\u706d&#8230;.\u54c8\u54c8\u54c8\uff0c\u5938\u5f20\u4e86\u3002\u4f46\u5b9e\u9645\u751f\u4ea7\u73af\u5883\u4e2d\u786e\u5b9e\u5b58\u5728\u9690\u60a3\u95ee\u9898\uff0c\u7531\u4e8eNginx\u4f5c\u4e3a\u6574\u4e2a\u7cfb\u7edf\u7684\u7f51\u5173\u5c42\u63a5\u5165\u5916\u90e8\u6d41\u91cf\uff0c\u6240\u4ee5\u4e00\u65e6Nginx\u5b95\u673a\uff0c\u6700\u7ec8\u5c31\u4f1a\u5bfc\u81f4\u6574\u4e2a\u7cfb\u7edf\u4e0d\u53ef\u7528\uff0c\u8fd9\u65e0\u7591\u5bf9\u4e8e\u7528\u6237\u7684\u4f53\u9a8c\u611f\u662f\u6781\u5dee\u7684\uff0c\u56e0\u6b64\u4e5f\u5f97\u4fdd\u969cNginx\u9ad8\u53ef\u7528\u7684\u7279\u6027\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u63a5\u4e0b\u6765\u5219\u4f1a\u901a\u8fc7keepalived\u7684VIP\u673a\u5236\uff0c\u5b9e\u73b0Nginx\u7684\u9ad8\u53ef\u7528\u3002VIP\u5e76\u4e0d\u662f\u53ea\u4f1a\u5458\u7684\u610f\u601d\uff0c\u800c\u662f\u6307Virtual IP\uff0c\u5373\u865a\u62dfIP\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">keepalived\u5728\u4e4b\u524d\u5355\u4f53\u67b6\u6784\u5f00\u53d1\u65f6\uff0c\u662f\u4e00\u4e2a\u7528\u7684\u8f83\u4e3a\u9891\u7e41\u7684\u9ad8\u53ef\u7528\u6280\u672f\uff0c\u6bd4\u5982MySQL\u3001Redis\u3001MQ\u3001Proxy\u3001Tomcat\u7b49\u5404\u5904\u90fd\u4f1a\u901a\u8fc7keepalived\u63d0\u4f9b\u7684VIP\u673a\u5236\uff0c\u5b9e\u73b0\u5355\u8282\u70b9\u5e94\u7528\u7684\u9ad8\u53ef\u7528\u3002<\/p>\n<h4> <span><\/span>Keepalived+\u91cd\u542f\u811a\u672c+\u53cc\u673a\u70ed\u5907\u642d\u5efa<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2460\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u5bf9\u5e94\u7684\u76ee\u5f55\u5e76\u4e0b\u8f7dkeepalived\u5230Linux\u4e2d\u5e76\u89e3\u538b\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;mkdir&nbsp;\/soft\/keepalived&nbsp;&amp;amp;&amp;amp;&nbsp;cd&nbsp;\/soft\/keepalived&nbsp;&nbsp;\n[root@localhost]#&nbsp;wget&nbsp;https:\/\/www.keepalived.org\/software\/keepalived-2.2.4.tar.gz&nbsp;&nbsp;\n[root@localhost]#&nbsp;tar&nbsp;-zxvf&nbsp;keepalived-2.2.4.tar.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2461\u8fdb\u5165\u89e3\u538b\u540e\u7684keepalived\u76ee\u5f55\u5e76\u6784\u5efa\u5b89\u88c5\u73af\u5883\uff0c\u7136\u540e\u7f16\u8bd1\u5e76\u5b89\u88c5\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;cd&nbsp;keepalived-2.2.4&nbsp;&nbsp;\n[root@localhost]#&nbsp;.\/configure&nbsp;--prefix=\/soft\/keepalived\/&nbsp;&nbsp;\n[root@localhost]#&nbsp;make&nbsp;&amp;amp;&amp;amp;&nbsp;make&nbsp;install<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2462\u8fdb\u5165\u5b89\u88c5\u76ee\u5f55\u7684\/soft\/keepalived\/etc\/keepalived\/\u5e76\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;cd&nbsp;\/soft\/keepalived\/etc\/keepalived\/&nbsp;&nbsp;\n[root@localhost]#&nbsp;vi&nbsp;keepalived.conf<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2463\u7f16\u8f91\u4e3b\u673a\u7684keepalived.conf\u6838\u5fc3\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>global_defs&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u81ea\u5e26\u7684\u90ae\u4ef6\u63d0\u9192\u670d\u52a1\uff0c\u5efa\u8bae\u7528\u72ec\u7acb\u7684\u76d1\u63a7\u6216\u7b2c\u4e09\u65b9SMTP\uff0c\u4e5f\u53ef\u9009\u62e9\u914d\u7f6e\u90ae\u4ef6\u53d1\u9001\u3002&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;notification_email&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root@localhost&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;notification_email_from&nbsp;root@localhost&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;smtp_server&nbsp;localhost&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;smtp_connect_timeout&nbsp;30&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u9ad8\u53ef\u7528\u96c6\u7fa4\u4e3b\u673a\u8eab\u4efd\u6807\u8bc6(\u96c6\u7fa4\u4e2d\u4e3b\u673a\u8eab\u4efd\u6807\u8bc6\u540d\u79f0\u4e0d\u80fd\u91cd\u590d\uff0c\u5efa\u8bae\u914d\u7f6e\u6210\u672c\u673aIP)&nbsp;&nbsp;\n&nbsp;router_id&nbsp;192.168.12.129&nbsp;&nbsp;&nbsp;\n}&nbsp;&nbsp;\n&nbsp;&nbsp;\n#&nbsp;\u5b9a\u65f6\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u914d\u7f6e&nbsp;&nbsp;\nvrrp_script&nbsp;check_nginx_pid_restart&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4e4b\u524d\u7f16\u5199\u7684nginx\u91cd\u542f\u811a\u672c\u7684\u6240\u5728\u4f4d\u7f6e&nbsp;&nbsp;\n&nbsp;script&nbsp;\"\/soft\/scripts\/keepalived\/check_nginx_pid_restart.sh\"&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6bcf\u95f4\u96943\u79d2\u6267\u884c\u4e00\u6b21&nbsp;&nbsp;\n&nbsp;interval&nbsp;3&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5982\u679c\u811a\u672c\u4e2d\u7684\u6761\u4ef6\u6210\u7acb\uff0c\u91cd\u542f\u4e00\u6b21\u5219\u6743\u91cd-20&nbsp;&nbsp;\n&nbsp;weight&nbsp;-20&nbsp;&nbsp;\n}&nbsp;&nbsp;\n&nbsp;&nbsp;\n#&nbsp;\u5b9a\u4e49\u865a\u62df\u8def\u7531\uff0cVI_1\u4e3a\u865a\u62df\u8def\u7531\u7684\u6807\u793a\u7b26\uff08\u53ef\u81ea\u5b9a\u4e49\u540d\u79f0\uff09&nbsp;&nbsp;\nvrrp_instance&nbsp;VI_1&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5f53\u524d\u8282\u70b9\u7684\u8eab\u4efd\u6807\u8bc6\uff1a\u7528\u6765\u51b3\u5b9a\u4e3b\u4ece\uff08MASTER\u4e3a\u4e3b\u673a\uff0cBACKUP\u4e3a\u4ece\u673a\uff09&nbsp;&nbsp;\n&nbsp;state&nbsp;MASTER&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u7ed1\u5b9a\u865a\u62dfIP\u7684\u7f51\u7edc\u63a5\u53e3\uff0c\u6839\u636e\u81ea\u5df1\u7684\u673a\u5668\u7684\u7f51\u5361\u914d\u7f6e&nbsp;&nbsp;\n&nbsp;interface&nbsp;ens33&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u865a\u62df\u8def\u7531\u7684ID\u53f7\uff0c\u4e3b\u4ece\u4e24\u4e2a\u8282\u70b9\u8bbe\u7f6e\u5fc5\u987b\u4e00\u6837&nbsp;&nbsp;\n&nbsp;virtual_router_id&nbsp;121&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u586b\u5199\u672c\u673aIP&nbsp;&nbsp;\n&nbsp;mcast_src_ip&nbsp;192.168.12.129&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8282\u70b9\u6743\u91cd\u4f18\u5148\u7ea7\uff0c\u4e3b\u8282\u70b9\u8981\u6bd4\u4ece\u8282\u70b9\u4f18\u5148\u7ea7\u9ad8&nbsp;&nbsp;\n&nbsp;priority&nbsp;100&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4f18\u5148\u7ea7\u9ad8\u7684\u8bbe\u7f6enopreempt\uff0c\u89e3\u51b3\u5f02\u5e38\u6062\u590d\u540e\u518d\u6b21\u62a2\u5360\u9020\u6210\u7684\u8111\u88c2\u95ee\u9898&nbsp;&nbsp;\n&nbsp;nopreempt&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u7ec4\u64ad\u4fe1\u606f\u53d1\u9001\u95f4\u9694\uff0c\u4e24\u4e2a\u8282\u70b9\u8bbe\u7f6e\u5fc5\u987b\u4e00\u6837\uff0c\u9ed8\u8ba41s\uff08\u7c7b\u4f3c\u4e8e\u5fc3\u8df3\u68c0\u6d4b\uff09&nbsp;&nbsp;\n&nbsp;advert_int&nbsp;1&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;authentication&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_type&nbsp;PASS&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_pass&nbsp;1111&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5c06track_script\u5757\u52a0\u5165instance\u914d\u7f6e\u5757&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;track_script&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6267\u884cNginx\u76d1\u63a7\u7684\u811a\u672c&nbsp;&nbsp;\n&nbsp;&nbsp;check_nginx_pid_restart&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;virtual_ipaddress&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u865a\u62dfIP(VIP)\uff0c\u4e5f\u53ef\u6269\u5c55\uff0c\u53ef\u914d\u7f6e\u591a\u4e2a\u3002&nbsp;&nbsp;\n&nbsp;&nbsp;192.168.12.111&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2464\u514b\u9686\u4e00\u53f0\u4e4b\u524d\u7684\u865a\u62df\u673a\u4f5c\u4e3a\u4ece\uff08\u5907\uff09\u673a\uff0c\u7f16\u8f91\u4ece\u673a\u7684keepalived.conf\u6587\u4ef6\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>global_defs&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u81ea\u5e26\u7684\u90ae\u4ef6\u63d0\u9192\u670d\u52a1\uff0c\u5efa\u8bae\u7528\u72ec\u7acb\u7684\u76d1\u63a7\u6216\u7b2c\u4e09\u65b9SMTP\uff0c\u4e5f\u53ef\u9009\u62e9\u914d\u7f6e\u90ae\u4ef6\u53d1\u9001\u3002&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;notification_email&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root@localhost&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;notification_email_from&nbsp;root@localhost&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;smtp_server&nbsp;localhost&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;smtp_connect_timeout&nbsp;30&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u9ad8\u53ef\u7528\u96c6\u7fa4\u4e3b\u673a\u8eab\u4efd\u6807\u8bc6(\u96c6\u7fa4\u4e2d\u4e3b\u673a\u8eab\u4efd\u6807\u8bc6\u540d\u79f0\u4e0d\u80fd\u91cd\u590d\uff0c\u5efa\u8bae\u914d\u7f6e\u6210\u672c\u673aIP)&nbsp;&nbsp;\n&nbsp;router_id&nbsp;192.168.12.130&nbsp;&nbsp;&nbsp;\n}&nbsp;&nbsp;\n&nbsp;&nbsp;\n#&nbsp;\u5b9a\u65f6\u8fd0\u884c\u7684\u811a\u672c\u6587\u4ef6\u914d\u7f6e&nbsp;&nbsp;\nvrrp_script&nbsp;check_nginx_pid_restart&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4e4b\u524d\u7f16\u5199\u7684nginx\u91cd\u542f\u811a\u672c\u7684\u6240\u5728\u4f4d\u7f6e&nbsp;&nbsp;\n&nbsp;script&nbsp;\"\/soft\/scripts\/keepalived\/check_nginx_pid_restart.sh\"&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6bcf\u95f4\u96943\u79d2\u6267\u884c\u4e00\u6b21&nbsp;&nbsp;\n&nbsp;interval&nbsp;3&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5982\u679c\u811a\u672c\u4e2d\u7684\u6761\u4ef6\u6210\u7acb\uff0c\u91cd\u542f\u4e00\u6b21\u5219\u6743\u91cd-20&nbsp;&nbsp;\n&nbsp;weight&nbsp;-20&nbsp;&nbsp;\n}&nbsp;&nbsp;\n&nbsp;&nbsp;\n#&nbsp;\u5b9a\u4e49\u865a\u62df\u8def\u7531\uff0cVI_1\u4e3a\u865a\u62df\u8def\u7531\u7684\u6807\u793a\u7b26\uff08\u53ef\u81ea\u5b9a\u4e49\u540d\u79f0\uff09&nbsp;&nbsp;\nvrrp_instance&nbsp;VI_1&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5f53\u524d\u8282\u70b9\u7684\u8eab\u4efd\u6807\u8bc6\uff1a\u7528\u6765\u51b3\u5b9a\u4e3b\u4ece\uff08MASTER\u4e3a\u4e3b\u673a\uff0cBACKUP\u4e3a\u4ece\u673a\uff09&nbsp;&nbsp;\n&nbsp;state&nbsp;BACKUP&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u7ed1\u5b9a\u865a\u62dfIP\u7684\u7f51\u7edc\u63a5\u53e3\uff0c\u6839\u636e\u81ea\u5df1\u7684\u673a\u5668\u7684\u7f51\u5361\u914d\u7f6e&nbsp;&nbsp;\n&nbsp;interface&nbsp;ens33&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u865a\u62df\u8def\u7531\u7684ID\u53f7\uff0c\u4e3b\u4ece\u4e24\u4e2a\u8282\u70b9\u8bbe\u7f6e\u5fc5\u987b\u4e00\u6837&nbsp;&nbsp;\n&nbsp;virtual_router_id&nbsp;121&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u586b\u5199\u672c\u673aIP&nbsp;&nbsp;\n&nbsp;mcast_src_ip&nbsp;192.168.12.130&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8282\u70b9\u6743\u91cd\u4f18\u5148\u7ea7\uff0c\u4e3b\u8282\u70b9\u8981\u6bd4\u4ece\u8282\u70b9\u4f18\u5148\u7ea7\u9ad8&nbsp;&nbsp;\n&nbsp;priority&nbsp;90&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4f18\u5148\u7ea7\u9ad8\u7684\u8bbe\u7f6enopreempt\uff0c\u89e3\u51b3\u5f02\u5e38\u6062\u590d\u540e\u518d\u6b21\u62a2\u5360\u9020\u6210\u7684\u8111\u88c2\u95ee\u9898&nbsp;&nbsp;\n&nbsp;nopreempt&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u7ec4\u64ad\u4fe1\u606f\u53d1\u9001\u95f4\u9694\uff0c\u4e24\u4e2a\u8282\u70b9\u8bbe\u7f6e\u5fc5\u987b\u4e00\u6837\uff0c\u9ed8\u8ba41s\uff08\u7c7b\u4f3c\u4e8e\u5fc3\u8df3\u68c0\u6d4b\uff09&nbsp;&nbsp;\n&nbsp;advert_int&nbsp;1&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;authentication&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_type&nbsp;PASS&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_pass&nbsp;1111&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5c06track_script\u5757\u52a0\u5165instance\u914d\u7f6e\u5757&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;track_script&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6267\u884cNginx\u76d1\u63a7\u7684\u811a\u672c&nbsp;&nbsp;\n&nbsp;&nbsp;check_nginx_pid_restart&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;virtual_ipaddress&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u865a\u62dfIP(VIP)\uff0c\u4e5f\u53ef\u6269\u5c55\uff0c\u53ef\u914d\u7f6e\u591a\u4e2a\u3002&nbsp;&nbsp;\n&nbsp;&nbsp;192.168.12.111&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2465\u65b0\u5efascripts\u76ee\u5f55\u5e76\u7f16\u5199Nginx\u7684\u91cd\u542f\u811a\u672c\uff0ccheck_nginx_pid_restart.sh\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;mkdir&nbsp;\/soft\/scripts&nbsp;\/soft\/scripts\/keepalived&nbsp;&nbsp;\n[root@localhost]#&nbsp;touch&nbsp;\/soft\/scripts\/keepalived\/check_nginx_pid_restart.sh&nbsp;&nbsp;\n[root@localhost]#&nbsp;vi&nbsp;\/soft\/scripts\/keepalived\/check_nginx_pid_restart.sh&nbsp;&nbsp;\n&nbsp;&nbsp;\n#!\/bin\/sh&nbsp;&nbsp;\n#&nbsp;\u901a\u8fc7ps\u6307\u4ee4\u67e5\u8be2\u540e\u53f0\u7684nginx\u8fdb\u7a0b\u6570\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u5728\u53d8\u91cfnginx_number\u4e2d&nbsp;&nbsp;\nnginx_number=`ps&nbsp;-C&nbsp;nginx&nbsp;--no-header&nbsp;|&nbsp;wc&nbsp;-l`&nbsp;&nbsp;\n#&nbsp;\u5224\u65ad\u540e\u53f0\u662f\u5426\u8fd8\u6709Nginx\u8fdb\u7a0b\u5728\u8fd0\u884c&nbsp;&nbsp;\nif&nbsp;[&nbsp;$nginx_number&nbsp;-eq&nbsp;0&nbsp;];then&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5982\u679c\u540e\u53f0\u67e5\u8be2\u4e0d\u5230`Nginx`\u8fdb\u7a0b\u5b58\u5728\uff0c\u5219\u6267\u884c\u91cd\u542f\u6307\u4ee4&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;\/soft\/nginx\/sbin\/nginx&nbsp;-c&nbsp;\/soft\/nginx\/conf\/nginx.conf&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u91cd\u542f\u540e\u7b49\u5f851s\u540e\uff0c\u518d\u6b21\u67e5\u8be2\u540e\u53f0\u8fdb\u7a0b\u6570&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;sleep&nbsp;1&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5982\u679c\u91cd\u542f\u540e\u4f9d\u65e7\u65e0\u6cd5\u67e5\u8be2\u5230nginx\u8fdb\u7a0b&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;[&nbsp;`ps&nbsp;-C&nbsp;nginx&nbsp;--no-header&nbsp;|&nbsp;wc&nbsp;-l`&nbsp;-eq&nbsp;0&nbsp;];then&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u5c06keepalived\u4e3b\u673a\u4e0b\u7ebf\uff0c\u5c06\u865a\u62dfIP\u6f02\u79fb\u7ed9\u4ece\u673a\uff0c\u4ece\u673a\u4e0a\u7ebf\u63a5\u7ba1Nginx\u670d\u52a1&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;systemctl&nbsp;stop&nbsp;keepalived.service&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;fi&nbsp;&nbsp;\nfi<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2466\u7f16\u5199\u7684\u811a\u672c\u6587\u4ef6\u9700\u8981\u66f4\u6539\u7f16\u7801\u683c\u5f0f\uff0c\u5e76\u8d4b\u4e88\u6267\u884c\u6743\u9650\uff0c\u5426\u5219\u53ef\u80fd\u6267\u884c\u5931\u8d25\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;vi&nbsp;\/soft\/scripts\/keepalived\/check_nginx_pid_restart.sh&nbsp;&nbsp;\n&nbsp;&nbsp;\n:set&nbsp;fileformat=unix&nbsp;#&nbsp;\u5728vi\u547d\u4ee4\u91cc\u9762\u6267\u884c\uff0c\u4fee\u6539\u7f16\u7801\u683c\u5f0f&nbsp;&nbsp;\n:set&nbsp;ff&nbsp;#&nbsp;\u67e5\u770b\u4fee\u6539\u540e\u7684\u7f16\u7801\u683c\u5f0f&nbsp;&nbsp;\n&nbsp;&nbsp;\n[root@localhost]#&nbsp;chmod&nbsp;+x&nbsp;\/soft\/scripts\/keepalived\/check_nginx_pid_restart.sh<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2467\u7531\u4e8e\u5b89\u88c5keepalived\u65f6\uff0c\u662f\u81ea\u5b9a\u4e49\u7684\u5b89\u88c5\u4f4d\u7f6e\uff0c\u56e0\u6b64\u9700\u8981\u62f7\u8d1d\u4e00\u4e9b\u6587\u4ef6\u5230\u7cfb\u7edf\u76ee\u5f55\u4e2d\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;mkdir&nbsp;\/etc\/keepalived\/&nbsp;&nbsp;\n[root@localhost]#&nbsp;cp&nbsp;\/soft\/keepalived\/etc\/keepalived\/keepalived.conf&nbsp;\/etc\/keepalived\/&nbsp;&nbsp;\n[root@localhost]#&nbsp;cp&nbsp;\/soft\/keepalived\/keepalived-2.2.4\/keepalived\/etc\/init.d\/keepalived&nbsp;\/etc\/init.d\/&nbsp;&nbsp;\n[root@localhost]#&nbsp;cp&nbsp;\/soft\/keepalived\/etc\/sysconfig\/keepalived&nbsp;\/etc\/sysconfig\/<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2468\u5c06keepalived\u52a0\u5165\u7cfb\u7edf\u670d\u52a1\u5e76\u8bbe\u7f6e\u5f00\u542f\u81ea\u542f\u52a8\uff0c\u7136\u540e\u6d4b\u8bd5\u542f\u52a8\u662f\u5426\u6b63\u5e38\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;chkconfig&nbsp;keepalived&nbsp;on&nbsp;&nbsp;\n[root@localhost]#&nbsp;systemctl&nbsp;daemon-reload&nbsp;&nbsp;\n[root@localhost]#&nbsp;systemctl&nbsp;enable&nbsp;keepalived.service&nbsp;&nbsp;\n[root@localhost]#&nbsp;systemctl&nbsp;start&nbsp;keepalived.service<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5176\u4ed6\u547d\u4ee4\uff1a<\/p>\n<pre>systemctl&nbsp;disable&nbsp;keepalived.service&nbsp;#&nbsp;\u7981\u6b62\u5f00\u673a\u81ea\u52a8\u542f\u52a8&nbsp;&nbsp;\nsystemctl&nbsp;restart&nbsp;keepalived.service&nbsp;#&nbsp;\u91cd\u542fkeepalived&nbsp;&nbsp;\nsystemctl&nbsp;stop&nbsp;keepalived.service&nbsp;#&nbsp;\u505c\u6b62keepalived&nbsp;&nbsp;\ntail&nbsp;-f&nbsp;\/var\/log\/messages&nbsp;#&nbsp;\u67e5\u770bkeepalived\u8fd0\u884c\u65f6\u65e5\u5fd7<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u2469\u6700\u540e\u6d4b\u8bd5\u4e00\u4e0bVIP\u662f\u5426\u751f\u6548\uff0c\u901a\u8fc7\u67e5\u770b\u672c\u673a\u662f\u5426\u6210\u529f\u6302\u8f7d\u865a\u62dfIP\uff1a<\/p>\n<pre>[root@localhost]#&nbsp;ip&nbsp;addr<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/e5a8f9763674d456214d666800218afc-12.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe13\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe13\" \/>\u865a\u62dfIP-VIP<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4ece\u4e0a\u56fe\u4e2d\u53ef\u4ee5\u660e\u663e\u770b\u89c1\u865a\u62dfIP\u5df2\u7ecf\u6210\u529f\u6302\u8f7d\uff0c\u4f46\u53e6\u5916\u4e00\u53f0\u673a\u5668192.168.12.130\u5e76\u4e0d\u4f1a\u6302\u8f7d\u8fd9\u4e2a\u865a\u62dfIP\uff0c\u53ea\u6709\u5f53\u4e3b\u673a\u4e0b\u7ebf\u540e\uff0c\u4f5c\u4e3a\u4ece\u673a\u7684192.168.12.130\u624d\u4f1a\u4e0a\u7ebf\uff0c\u63a5\u66ffVIP\u3002\u6700\u540e\u6d4b\u8bd5\u4e00\u4e0b\u5916\u7f51\u662f\u5426\u53ef\u4ee5\u6b63\u5e38\u4e0eVIP\u901a\u4fe1\uff0c\u5373\u5728Windows\u4e2d\u76f4\u63a5ping VIP\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/e5a8f9763674d456214d666800218afc-13.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe14\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe14\" \/>Ping-VIP<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5916\u90e8\u901a\u8fc7VIP\u901a\u4fe1\u65f6\uff0c\u4e5f\u53ef\u4ee5\u6b63\u5e38Ping\u901a\uff0c\u4ee3\u8868\u865a\u62dfIP\u914d\u7f6e\u6210\u529f\u3002<\/p>\n<h4> <span><\/span>Nginx\u9ad8\u53ef\u7528\u6027\u6d4b\u8bd5<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7ecf\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0ckeepalived\u7684VIP\u673a\u5236\u5df2\u7ecf\u642d\u5efa\u6210\u529f\uff0c\u5728\u4e0a\u4e2a\u9636\u6bb5\u4e2d\u4e3b\u8981\u505a\u4e86\u51e0\u4ef6\u4e8b\uff1a<\/p>\n<ul>\n<li> \u4e00\u3001\u4e3a\u90e8\u7f72Nginx\u7684\u673a\u5668\u6302\u8f7d\u4e86VIP\u3002 <\/li>\n<li> \u4e8c\u3001\u901a\u8fc7keepalived\u642d\u5efa\u4e86\u4e3b\u4ece\u53cc\u673a\u70ed\u5907\u3002 <\/li>\n<li> \u4e09\u3001\u901a\u8fc7keepalived\u5b9e\u73b0\u4e86Nginx\u5b95\u673a\u91cd\u542f\u3002 <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7531\u4e8e\u524d\u9762\u6ca1\u6709\u57df\u540d\u7684\u539f\u56e0\uff0c\u56e0\u6b64\u6700\u521dserver_name\u914d\u7f6e\u7684\u662f\u5f53\u524d\u673a\u5668\u7684IP\uff0c\u6240\u4ee5\u9700\u7a0d\u5fae\u66f4\u6539\u4e00\u4e0bnginx.conf\u7684\u914d\u7f6e\uff1a<\/p>\n<pre>sever{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;80;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8fd9\u91cc\u4ece\u673a\u5668\u7684\u672c\u5730IP\u6539\u4e3a\u865a\u62dfIP&nbsp;&nbsp;\n&nbsp;server_name&nbsp;192.168.12.111;&nbsp;&nbsp;\n&nbsp;#&nbsp;\u5982\u679c\u8fd9\u91cc\u914d\u7f6e\u7684\u662f\u57df\u540d\uff0c\u90a3\u4e48\u5219\u5c06\u57df\u540d\u7684\u6620\u5c04\u914d\u7f6e\u6539\u4e3a\u865a\u62dfIP&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6700\u540e\u6765\u5b9e\u9a8c\u4e00\u4e0b\u6548\u679c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/e5a8f9763674d456214d666800218afc-14.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe15\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe15\" \/> <\/p>\n<p style=\"max-width:90%\">\u5728\u4e0a\u8ff0\u8fc7\u7a0b\u4e2d\uff0c\u9996\u5148\u5206\u522b\u542f\u52a8\u4e86keepalived\u3001nginx\u670d\u52a1\uff0c\u7136\u540e\u901a\u8fc7\u624b\u52a8\u505c\u6b62nginx\u7684\u65b9\u5f0f\u6a21\u62df\u4e86Nginx\u5b95\u673a\u60c5\u51b5\uff0c\u8fc7\u4e86\u7247\u523b\u540e\u518d\u6b21\u67e5\u8be2\u540e\u53f0\u8fdb\u7a0b\uff0c\u6211\u4eec\u4f1a\u53d1\u73b0nginx\u4f9d\u65e7\u5b58\u6d3b\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4ece\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u4e0d\u96be\u53d1\u73b0\uff0ckeepalived\u5df2\u7ecf\u4e3a\u6211\u4eec\u5b9e\u73b0\u4e86Nginx\u5b95\u673a\u540e\u81ea\u52a8\u91cd\u542f\u7684\u529f\u80fd\uff0c\u90a3\u4e48\u63a5\u7740\u518d\u6a21\u62df\u4e00\u4e0b\u670d\u52a1\u5668\u51fa\u73b0\u6545\u969c\u65f6\u7684\u60c5\u51b5\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/04cfcde19a7d7db3d497715052e1f1f7-15.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe16\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe16\" \/> <\/p>\n<p style=\"max-width:90%\">\u5728\u4e0a\u8ff0\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7\u624b\u52a8\u5173\u95edkeepalived\u670d\u52a1\u6a21\u62df\u4e86\u673a\u5668\u65ad\u7535\u3001\u786c\u4ef6\u635f\u574f\u7b49\u60c5\u51b5\uff08\u56e0\u4e3a\u673a\u5668\u65ad\u7535\u7b49\u60c5\u51b5=\u4e3b\u673a\u4e2d\u7684keepalived\u8fdb\u7a0b\u6d88\u5931\uff09\uff0c\u7136\u540e\u518d\u6b21\u67e5\u8be2\u4e86\u4e00\u4e0b\u672c\u673a\u7684IP\u4fe1\u606f\uff0c\u5f88\u660e\u663e\u4f1a\u770b\u5230VIP\u6d88\u5931\u4e86\uff01<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u73b0\u5728\u518d\u5207\u6362\u5230\u53e6\u5916\u4e00\u53f0\u673a\u5668\uff1a192.168.12.130\u6765\u770b\u770b\u60c5\u51b5\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/273\/727\/04cfcde19a7d7db3d497715052e1f1f7-16.jpg\" class=\"aligncenter\" title=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe17\" alt=\"14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\u63d2\u56fe17\" \/> <\/p>\n<p style=\"max-width:90%\">\u6b64\u523b\u6211\u4eec\u4f1a\u53d1\u73b0\uff0c\u5728\u4e3b\u673a192.168.12.129\u5b95\u673a\u540e\uff0cVIP\u81ea\u52a8\u4ece\u4e3b\u673a\u98d8\u79fb\u5230\u4e86\u4ece\u673a192.168.12.130\u4e0a\uff0c\u800c\u6b64\u65f6\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u5c31\u6700\u7ec8\u4f1a\u6765\u5230130\u8fd9\u53f0\u673a\u5668\u7684Nginx\u4e0a\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\"><strong>\u300c\u300c\u6700\u7ec8\uff0c\u5229\u7528Keepalived\u5bf9Nginx\u505a\u4e86\u4e3b\u4ece\u70ed\u5907\u4e4b\u540e\uff0c\u65e0\u8bba\u662f\u9047\u5230\u7ebf\u4e0a\u5b95\u673a\u8fd8\u662f\u673a\u623f\u65ad\u7535\u7b49\u5404\u7c7b\u6545\u969c\u65f6\uff0c\u90fd\u80fd\u591f\u786e\u4fdd\u5e94\u7528\u7cfb\u7edf\u80fd\u591f\u4e3a\u7528\u6237\u63d0\u4f9b7&#215;24\u5c0f\u65f6\u670d\u52a1\u3002\u300d\u300d<\/strong><\/p>\n<h3> <span><\/span>\u5341\u56db\u3001Nginx\u6027\u80fd\u4f18\u5316<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5230\u8fd9\u91cc\u6587\u7ae0\u7684\u7bc7\u5e45\u8f83\u957f\u4e86\uff0c\u6700\u540e\u518d\u6765\u804a\u4e00\u4e0b\u5173\u4e8eNginx\u7684\u6027\u80fd\u4f18\u5316\uff0c\u4e3b\u8981\u5c31\u7b80\u5355\u8bf4\u8bf4\u6536\u76ca\u6700\u9ad8\u7684\u51e0\u4e2a\u4f18\u5316\u9879\uff0c\u5728\u8fd9\u5757\u5c31\u4e0d\u518d\u5c55\u5f00\u53d9\u8ff0\u4e86\uff0c\u6bd5\u7adf\u5f71\u54cd\u6027\u80fd\u90fd\u6709\u591a\u65b9\u9762\u539f\u56e0\u5bfc\u81f4\u7684\uff0c\u6bd4\u5982\u7f51\u7edc\u3001\u670d\u52a1\u5668\u786c\u4ef6\u3001\u64cd\u4f5c\u7cfb\u7edf\u3001\u540e\u7aef\u670d\u52a1\u3001\u7a0b\u5e8f\u81ea\u8eab\u3001\u6570\u636e\u5e93\u670d\u52a1\u7b49\u3002<\/p>\n<h4> <span><\/span>\u4f18\u5316\u4e00\uff1a\u6253\u5f00\u957f\u8fde\u63a5\u914d\u7f6e<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u901a\u5e38Nginx\u4f5c\u4e3a\u4ee3\u7406\u670d\u52a1\uff0c\u8d1f\u8d23\u5206\u53d1\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff0c\u90a3\u4e48\u5efa\u8bae\u5f00\u542fHTTP\u957f\u8fde\u63a5\uff0c\u7528\u6237\u51cf\u5c11\u63e1\u624b\u7684\u6b21\u6570\uff0c\u964d\u4f4e\u670d\u52a1\u5668\u635f\u8017\uff0c\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n<pre>upstream&nbsp;xxx&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u957f\u8fde\u63a5\u6570&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;keepalive&nbsp;32;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6bcf\u4e2a\u957f\u8fde\u63a5\u63d0\u4f9b\u7684\u6700\u5927\u8bf7\u6c42\u6570&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;keepalived_requests&nbsp;100;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u6bcf\u4e2a\u957f\u8fde\u63a5\u6ca1\u6709\u65b0\u7684\u8bf7\u6c42\u65f6\uff0c\u4fdd\u6301\u7684\u6700\u957f\u65f6\u95f4&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;keepalive_timeout&nbsp;60s;&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4> <span><\/span>\u4f18\u5316\u4e8c\u3001\u5f00\u542f\u96f6\u62f7\u8d1d\u6280\u672f<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u96f6\u62f7\u8d1d\u8fd9\u4e2a\u6982\u5ff5\uff0c\u5728\u5927\u591a\u6570\u6027\u80fd\u8f83\u4e3a\u4e0d\u9519\u7684\u4e2d\u95f4\u4ef6\u4e2d\u90fd\u6709\u51fa\u73b0\uff0c\u4f8b\u5982Kafka\u3001Netty\u7b49\uff0c\u800cNginx\u4e2d\u4e5f\u53ef\u4ee5\u914d\u7f6e\u6570\u636e\u96f6\u62f7\u8d1d\u6280\u672f\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>sendfile&nbsp;on;&nbsp;#&nbsp;\u5f00\u542f\u96f6\u62f7\u8d1d\u673a\u5236<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u96f6\u62f7\u8d1d\u8bfb\u53d6\u673a\u5236\u4e0e\u4f20\u7edf\u8d44\u6e90\u8bfb\u53d6\u673a\u5236\u7684\u533a\u522b\uff1a<\/p>\n<ul>\n<li> <strong>\u300c\u4f20\u7edf\u65b9\u5f0f\uff1a\u300d<\/strong> \u786c\u4ef6&#8211;&gt;\u5185\u6838&#8211;&gt;\u7528\u6237\u7a7a\u95f4&#8211;&gt;\u7a0b\u5e8f\u7a7a\u95f4&#8211;&gt;\u7a0b\u5e8f\u5185\u6838\u7a7a\u95f4&#8211;&gt;\u7f51\u7edc\u5957\u63a5\u5b57 <\/li>\n<li> <strong>\u300c\u96f6\u62f7\u8d1d\u65b9\u5f0f\uff1a\u300d<\/strong> \u786c\u4ef6&#8211;&gt;\u5185\u6838&#8211;&gt;\u7a0b\u5e8f\u5185\u6838\u7a7a\u95f4&#8211;&gt;\u7f51\u7edc\u5957\u63a5\u5b57 <\/li>\n<\/ul>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u4ece\u4e0a\u8ff0\u8fd9\u4e2a\u8fc7\u7a0b\u5bf9\u6bd4\uff0c\u5f88\u8f7b\u6613\u5c31\u80fd\u770b\u51fa\u4e24\u8005\u4e4b\u95f4\u7684\u6027\u80fd\u533a\u522b\u3002<\/p>\n<h4> <span><\/span>\u4f18\u5316\u4e09\u3001\u5f00\u542f\u65e0\u5ef6\u8fdf\u6216\u591a\u5305\u5171\u53d1\u673a\u5236<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728Nginx\u4e2d\u6709\u4e24\u4e2a\u8f83\u4e3a\u5173\u952e\u7684\u6027\u80fd\u53c2\u6570\uff0c\u5373tcp_nodelay\u3001tcp_nopush\uff0c\u5f00\u542f\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre>tcp_nodelay&nbsp;on;&nbsp;&nbsp;\ntcp_nopush&nbsp;on;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">TCP\/IP\u534f\u8bae\u4e2d\u9ed8\u8ba4\u662f\u91c7\u7528\u4e86Nagle\u7b97\u6cd5\u7684\uff0c\u5373\u5728\u7f51\u7edc\u6570\u636e\u4f20\u8f93\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u4e2a\u6570\u636e\u62a5\u6587\u5e76\u4e0d\u4f1a\u7acb\u9a6c\u53d1\u9001\u51fa\u53bb\uff0c\u800c\u662f\u4f1a\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\uff0c\u5c06\u540e\u9762\u7684\u51e0\u4e2a\u6570\u636e\u5305\u4e00\u8d77\u7ec4\u5408\u6210\u4e00\u4e2a\u6570\u636e\u62a5\u6587\u53d1\u9001\uff0c\u4f46\u8fd9\u4e2a\u7b97\u6cd5\u867d\u7136\u63d0\u9ad8\u4e86\u7f51\u7edc\u541e\u5410\u91cf\uff0c\u4f46\u662f\u5b9e\u65f6\u6027\u5374\u964d\u4f4e\u4e86\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u56e0\u6b64\u4f60\u7684\u9879\u76ee\u5c5e\u4e8e\u4ea4\u4e92\u6027\u5f88\u5f3a\u7684\u5e94\u7528\uff0c\u90a3\u4e48\u53ef\u4ee5\u624b\u52a8\u5f00\u542ftcp_nodelay\u914d\u7f6e\uff0c\u8ba9\u5e94\u7528\u7a0b\u5e8f\u5411\u5185\u6838\u9012\u4ea4\u7684\u6bcf\u4e2a\u6570\u636e\u5305\u90fd\u4f1a\u7acb\u5373\u53d1\u9001\u51fa\u53bb\u3002\u4f46\u8fd9\u6837\u4f1a\u4ea7\u751f\u5927\u91cf\u7684TCP\u62a5\u6587\u5934\uff0c\u589e\u52a0\u5f88\u5927\u7684\u7f51\u7edc\u5f00\u9500\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u76f8\u53cd\uff0c\u6709\u4e9b\u9879\u76ee\u7684\u4e1a\u52a1\u5bf9\u6570\u636e\u7684\u5b9e\u65f6\u6027\u8981\u6c42\u5e76\u4e0d\u9ad8\uff0c\u8ffd\u6c42\u7684\u5219\u662f\u66f4\u9ad8\u7684\u541e\u5410\uff0c\u90a3\u4e48\u5219\u53ef\u4ee5\u5f00\u542ftcp_nopush\u914d\u7f6e\u9879\uff0c\u8fd9\u4e2a\u914d\u7f6e\u5c31\u7c7b\u4f3c\u4e8e\u201c\u585e\u5b50\u201d\u7684\u610f\u601d\uff0c\u9996\u5148\u5c06\u8fde\u63a5\u585e\u4f4f\uff0c\u4f7f\u5f97\u6570\u636e\u5148\u4e0d\u53d1\u51fa\u53bb\uff0c\u7b49\u5230\u62d4\u53bb\u585e\u5b50\u540e\u518d\u53d1\u51fa\u53bb\u3002\u8bbe\u7f6e\u8be5\u9009\u9879\u540e\uff0c\u5185\u6838\u4f1a\u5c3d\u91cf\u628a\u5c0f\u6570\u636e\u5305\u62fc\u63a5\u6210\u4e00\u4e2a\u5927\u7684\u6570\u636e\u5305\uff08\u4e00\u4e2aMTU\uff09\u518d\u53d1\u9001\u51fa\u53bb.<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5f53\u7136\u82e5\u4e00\u5b9a\u65f6\u95f4\u540e\uff08\u4e00\u822c\u4e3a200ms\uff09\uff0c\u5185\u6838\u4ecd\u7136\u6ca1\u6709\u79ef\u7d2f\u5230\u4e00\u4e2aMTU\u7684\u91cf\u65f6\uff0c\u4e5f\u5fc5\u987b\u53d1\u9001\u73b0\u6709\u7684\u6570\u636e\uff0c\u5426\u5219\u4f1a\u4e00\u76f4\u963b\u585e\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">tcp_nodelay\u3001tcp_nopush\u4e24\u4e2a\u53c2\u6570\u662f\u201c\u4e92\u65a5\u201d\u7684\uff0c\u5982\u679c\u8ffd\u6c42\u54cd\u5e94\u901f\u5ea6\u7684\u5e94\u7528\u63a8\u8350\u5f00\u542ftcp_nodelay\u53c2\u6570\uff0c\u5982IM\u3001\u91d1\u878d\u7b49\u7c7b\u578b\u7684\u9879\u76ee\u3002\u5982\u679c\u8ffd\u6c42\u541e\u5410\u91cf\u7684\u5e94\u7528\u5219\u5efa\u8bae\u5f00\u542ftcp_nopush\u53c2\u6570\uff0c\u5982\u8c03\u5ea6\u7cfb\u7edf\u3001\u62a5\u8868\u7cfb\u7edf\u7b49\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6ce8\u610f\uff1a\u2460tcp_nodelay\u4e00\u822c\u8981\u5efa\u7acb\u5728\u5f00\u542f\u4e86\u957f\u8fde\u63a5\u6a21\u5f0f\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002\u2461tcp_nopush\u53c2\u6570\u662f\u5fc5\u987b\u8981\u5f00\u542fsendfile\u53c2\u6570\u624d\u53ef\u4f7f\u7528\u7684\u3002<\/p>\n<h4> <span><\/span>\u4f18\u5316\u56db\u3001\u8c03\u6574Worker\u5de5\u4f5c\u8fdb\u7a0b<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">Nginx\u542f\u52a8\u540e\u9ed8\u8ba4\u53ea\u4f1a\u5f00\u542f\u4e00\u4e2aWorker\u5de5\u4f5c\u8fdb\u7a0b\u5904\u7406\u5ba2\u6237\u7aef\u8bf7\u6c42\uff0c\u800c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u673a\u5668\u7684CPU\u6838\u6570\u5f00\u542f\u5bf9\u5e94\u6570\u91cf\u7684\u5de5\u4f5c\u8fdb\u7a0b\uff0c\u4ee5\u6b64\u6765\u63d0\u5347\u6574\u4f53\u7684\u5e76\u53d1\u91cf\u652f\u6301\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>#&nbsp;\u81ea\u52a8\u6839\u636eCPU\u6838\u5fc3\u6570\u8c03\u6574Worker\u8fdb\u7a0b\u6570\u91cf&nbsp;&nbsp;\nworker_processes&nbsp;auto;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5de5\u4f5c\u8fdb\u7a0b\u7684\u6570\u91cf\u6700\u9ad8\u5f00\u52308\u4e2a\u5c31OK\u4e86\uff0c8\u4e2a\u4e4b\u540e\u5c31\u4e0d\u4f1a\u6709\u518d\u5927\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u540c\u65f6\u4e5f\u53ef\u4ee5\u7a0d\u5fae\u8c03\u6574\u4e00\u4e0b\u6bcf\u4e2a\u5de5\u4f5c\u8fdb\u7a0b\u80fd\u591f\u6253\u5f00\u7684\u6587\u4ef6\u53e5\u67c4\u6570\uff1a<\/p>\n<pre>#&nbsp;\u6bcf\u4e2aWorker\u80fd\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u6700\u5c11\u8c03\u6574\u81f31W\u4ee5\u4e0a\uff0c\u8d1f\u8377\u8f83\u9ad8\u5efa\u8bae2-3W&nbsp;&nbsp;\nworker_rlimit_nofile&nbsp;20000;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\uff08kernel\uff09\u90fd\u662f\u5229\u7528\u6587\u4ef6\u63cf\u8ff0\u7b26\u6765\u8bbf\u95ee\u6587\u4ef6\uff0c\u65e0\u8bba\u662f\u6253\u5f00\u3001\u65b0\u5efa\u3001\u8bfb\u53d6\u3001\u5199\u5165\u6587\u4ef6\u65f6\uff0c\u90fd\u9700\u8981\u4f7f\u7528\u6587\u4ef6\u63cf\u8ff0\u7b26\u6765\u6307\u5b9a\u5f85\u64cd\u4f5c\u7684\u6587\u4ef6\uff0c\u56e0\u6b64\u8be5\u503c\u8d8a\u5927\uff0c\u4ee3\u8868\u4e00\u4e2a\u8fdb\u7a0b\u80fd\u591f\u64cd\u4f5c\u7684\u6587\u4ef6\u8d8a\u591a\uff08\u4f46\u4e0d\u80fd\u8d85\u51fa\u5185\u6838\u9650\u5236\uff0c\u6700\u591a\u5efa\u8bae3.8W\u5de6\u53f3\u4e3a\u4e0a\u9650\uff09\u3002<\/p>\n<h4> <span><\/span>\u4f18\u5316\u4e94\u3001\u5f00\u542fCPU\u4eb2\u548c\u673a\u5236<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5bf9\u4e8e\u5e76\u53d1\u7f16\u7a0b\u8f83\u4e3a\u719f\u6089\u7684\u4f19\u4f34\u90fd\u77e5\u9053\uff0c\u56e0\u4e3a\u8fdb\u7a0b\/\u7ebf\u7a0b\u6570\u5f80\u5f80\u90fd\u4f1a\u8fdc\u8d85\u51fa\u7cfb\u7edfCPU\u7684\u6838\u5fc3\u6570\uff0c\u56e0\u4e3a\u64cd\u4f5c\u7cfb\u7edf\u6267\u884c\u7684\u539f\u7406\u672c\u8d28\u4e0a\u662f\u91c7\u7528\u65f6\u95f4\u7247\u5207\u6362\u673a\u5236\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2aCPU\u6838\u5fc3\u4f1a\u5728\u591a\u4e2a\u8fdb\u7a0b\u4e4b\u95f4\u4e0d\u65ad\u9891\u7e41\u5207\u6362\uff0c\u9020\u6210\u5f88\u5927\u7684\u6027\u80fd\u635f\u8017\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u800cCPU\u4eb2\u548c\u673a\u5236\u5219\u662f\u6307\u5c06\u6bcf\u4e2aNginx\u7684\u5de5\u4f5c\u8fdb\u7a0b\uff0c\u7ed1\u5b9a\u5728\u56fa\u5b9a\u7684CPU\u6838\u5fc3\u4e0a\uff0c\u4ece\u800c\u51cf\u5c0fCPU\u5207\u6362\u5e26\u6765\u7684\u65f6\u95f4\u5f00\u9500\u548c\u8d44\u6e90\u635f\u8017\uff0c\u5f00\u542f\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre>worker_cpu_affinity&nbsp;auto;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4> <span><\/span>\u4f18\u5316\u516d\u3001\u5f00\u542fepoll\u6a21\u578b\u53ca\u8c03\u6574\u5e76\u53d1\u8fde\u63a5\u6570<span><\/span> <\/h4>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728\u6700\u5f00\u59cb\u5c31\u63d0\u5230\u8fc7\uff1aNginx\u3001Redis\u90fd\u662f\u57fa\u4e8e\u591a\u8def\u590d\u7528\u6a21\u578b\u53bb\u5b9e\u73b0\u7684\u7a0b\u5e8f\uff0c\u4f46\u6700\u521d\u7248\u7684\u591a\u8def\u590d\u7528\u6a21\u578bselect\/poll\u6700\u5927\u53ea\u80fd\u76d1\u542c1024\u4e2a\u8fde\u63a5\uff0c\u800cepoll\u5219\u5c5e\u4e8eselect\/poll\u63a5\u53e3\u7684\u589e\u5f3a\u7248\uff0c\u56e0\u6b64\u91c7\u7528\u8be5\u6a21\u578b\u80fd\u591f\u5927\u7a0b\u5ea6\u4e0a\u63d0\u5347\u5355\u4e2aWorker\u7684\u6027\u80fd\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>events&nbsp;{&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u4f7f\u7528epoll\u7f51\u7edc\u6a21\u578b&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;use&nbsp;epoll;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;\u8c03\u6574\u6bcf\u4e2aWorker\u80fd\u591f\u5904\u7406\u7684\u8fde\u63a5\u6570\u4e0a\u9650&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;worker_connections&nbsp;&nbsp;10240;&nbsp;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8fd9\u91cc\u5bf9\u4e8eselect\/poll\/epoll\u6a21\u578b\u5c31\u4e0d\u5c55\u5f00\u7ec6\u8bf4\u4e86\uff0c\u540e\u9762\u7684IO\u6a21\u578b\u6587\u7ae0\u4e2d\u4f1a\u8be6\u7ec6\u5256\u6790\u3002<\/p>\n<h3> <span><\/span>\u5341\u4e94\u3001\u653e\u5728\u6700\u540e\u7684\u7ed3\u5c3e<span><\/span> <\/h3>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u81f3\u6b64\uff0cNginx\u7684\u5927\u90e8\u5206\u5185\u5bb9\u90fd\u5df2\u9610\u8ff0\u5b8c\u6bd5\uff0c\u5173\u4e8e\u6700\u540e\u4e00\u5c0f\u8282\u7684\u6027\u80fd\u4f18\u5316\u5185\u5bb9\uff0c\u5176\u5b9e\u5728\u524d\u9762\u5c31\u8c08\u5230\u7684\u52a8\u9759\u5206\u79bb\u3001\u5206\u914d\u7f13\u51b2\u533a\u3001\u8d44\u6e90\u7f13\u5b58\u3001\u9632\u76d7\u94fe\u3001\u8d44\u6e90\u538b\u7f29\u7b49\u5185\u5bb9\uff0c\u4e5f\u90fd\u53ef\u5f52\u7eb3\u4e3a\u6027\u80fd\u4f18\u5316\u7684\u65b9\u6848\u3002<\/p>\n<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f14\u4e2aNginx\u7684\u6838\u5fc3\u529f\u80fd\u70b9\uff0c\u5efa\u8bae\u6536\u85cf\uff01\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>\u4eca\u5929\u6765\u548c\u5927\u5bb6\u804a\u804aNginx\u5728\u6211\u4eec\u5b9e\u9645\u5e94\u8fd0\u7528\u4e2d\u7684\u4e00\u4e9b\u975e\u5e38\u6709\u7528\u7684\u70b9\u3002 \u65e9\u671f\u7684\u4e1a\u52a1\u90fd\u662f\u57fa\u4e8e\u5355\u4f53\u8282\u70b9\u90e8\u7f72\uff0c\u7531\u4e8e\u524d\u671f\u8bbf\u95ee\u6d41\u91cf\u4e0d\u5927\uff0c\u56e0\u6b64\u5355\u4f53\u7ed3\u6784\u4e5f\u53ef\u6ee1\u8db3\u9700\u6c42\uff0c\u4f46\u968f\u7740\u4e1a\u52a1\u589e\u957f\uff0c\u6d41\u91cf\u4e5f\u8d8a\u6765\u8d8a\u5927\uff0c\u90a3\u4e48\u6700\u7ec8\u5355\u53f0\u670d\u52a1\u5668\u53d7\u5230\u7684\u8bbf\u95ee\u538b\u529b\u4e5f\u4f1a\u9010\u6b65\u589e\u9ad8\u3002\u65f6\u95f4\u4e00\u957f\uff0c\u5355\u53f0\u670d\u52a1\u5668\u6027\u80fd\u65e0\u6cd5\u8ddf\u4e0a\u4e1a\u52a1\u589e\u957f\uff0c\u5c31\u4f1a\u9020\u6210\u7ebf\u4e0a\u9891\u7e41\u5b95\u673a\u7684\u73b0\u8c61\u53d1\u751f\uff0c\u6700\u7ec8\u5bfc\u81f4\u7cfb\u7edf\u762b\u75ea\u65e0\u6cd5\u7ee7\u7eed\u5904\u7406\u7528\u6237\u7684\u8bf7\u6c42\u3002 \u4ece\u4e0a\u9762\u7684\u63cf\u8ff0\u4e2d\uff0c\u4e3b\u8981\u5b58\u5728\u4e24\u4e2a\u95ee\u9898\uff1a \u2460\u5355\u4f53\u7ed3\u6784\u7684\u90e8\u7f72\u65b9\u5f0f\u65e0\u6cd5\u627f\u8f7d\u65e5\u76ca\u589e\u957f\u7684\u4e1a\u52a1\u6d41\u91cf\u3002 \u2461\u5f53\u540e\u7aef\u8282\u70b9\u5b95\u673a\u540e\uff0c\u6574\u4e2a\u7cfb\u7edf\u4f1a\u9677\u5165\u762b\u75ea\uff0c\u5bfc\u81f4\u6574\u4e2a\u9879\u76ee\u4e0d\u53ef\u7528\u3002 \u56e0\u6b64\u5728\u8fd9\u79cd\u80cc\u666f\u4e0b\uff0c\u5f15\u5165\u8d1f\u8f7d\u5747\u8861\u6280\u672f\u53ef\u5e26\u6765\u7684\u6536\u76ca\uff1a \u300c\u7cfb\u7edf\u7684\u9ad8\u53ef\u7528\uff1a\u300d \u5f53\u67d0\u4e2a\u8282\u70b9\u5b95\u673a\u540e\u53ef\u4ee5\u8fc5\u901f\u5c06\u6d41\u91cf\u8f6c\u79fb\u81f3\u5176\u4ed6\u8282\u70b9\u3002 \u300c\u7cfb\u7edf\u7684\u9ad8\u6027\u80fd\uff1a\u300d \u591a\u53f0\u670d\u52a1\u5668\u5171\u540c\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\uff0c\u4e3a\u6574\u4e2a\u7cfb\u7edf\u63d0\u4f9b\u4e86\u66f4\u9ad8\u89c4\u6a21\u7684\u541e\u5410\u3002 \u300c\u7cfb\u7edf\u7684\u62d3\u5c55\u6027\uff1a\u300d \u5f53\u4e1a\u52a1\u518d\u6b21\u51fa\u73b0\u589e\u957f\u6216\u840e\u9761\u65f6\uff0c\u53ef\u518d\u52a0\u5165\/\u51cf\u5c11\u8282\u70b9\uff0c\u7075\u6d3b\u4f38\u7f29\u3002 OK~\uff0c\u65e2\u7136\u5f15\u5165\u8d1f\u8f7d\u5747\u8861\u6280\u672f\u53ef\u7ed9\u6211\u4eec\u5e26\u6765\u5982\u6b64\u5de8\u5927\u7684\u597d\u5904\uff0c\u90a3\u4e48\u53c8\u6709\u90a3\u4e9b\u65b9\u6848\u53ef\u4f9b\u9009\u62e9\u5462\uff1f\u4e3b\u8981\u6709\u4e24\u79cd\u8d1f\u8f7d\u65b9\u6848\uff0c\u300c\u300c\u786c\u4ef6\u5c42\u9762\u4e0e\u8f6f\u4ef6\u5c42\u9762\u300d\u300d \uff0c\u6bd4\u8f83\u5e38\u7528\u7684\u786c\u4ef6\u8d1f\u8f7d\u5668\u6709A10\u3001F5\u7b49\uff0c\u4f46\u8fd9\u4e9b\u673a\u5668\u52a8\u8f84\u5927\u51e0\u4e07\u4e43\u81f3\u51e0\u5341\u4e07\u7684\u6210\u672c\uff0c\u56e0\u6b64\u4e00\u822c\u5927\u578b\u4f01\u4e1a\u4f1a\u91c7\u7528\u8be5\u65b9\u6848\uff0c\u5982\u94f6\u884c\u3001\u56fd\u4f01\u3001\u592e\u4f01\u7b49\u3002\u800c\u6210\u672c\u6709\u9650\uff0c\u4f46\u4f9d\u65e7\u60f3\u505a\u8d1f\u8f7d\u5747\u8861\u7684\u9879\u76ee\uff0c\u90a3\u4e48\u53ef\u5728\u8f6f\u4ef6\u5c42\u9762\u5b9e\u73b0\uff0c\u5982\u5178\u578b\u7684Nginx\u7b49\uff0c\u8f6f\u4ef6\u5c42\u7684\u8d1f\u8f7d\u4e5f\u662f\u672c\u6587\u7684\u91cd\u70b9\uff0c\u6bd5\u7adfBoss\u4eec\u7684\u51c6\u5219\u4e4b\u4e00\u5c31\u662f\uff1a\u300c\u300c\u80fd\u9760\u6280\u672f\u5b9e\u73b0\u7684\u5c31\u5c3d\u91cf\u4e0d\u82b1\u94b1\u3002\u300d\u300d Java\u5f00\u53d1\u8005\u5728\u7ebf\u5237\u9898\u795e\u5668 \u4e00\u3001\u6027\u80fd\u602a\u517d-Nginx\u6982\u5ff5\u6df1\u5165\u6d45\u51fa Nginx\u662f\u76ee\u524d\u8d1f\u8f7d\u5747\u8861\u6280\u672f\u4e2d\u7684\u4e3b\u6d41\u65b9\u6848\uff0c\u51e0\u4e4e\u7edd\u5927\u90e8\u5206\u9879\u76ee\u90fd\u4f1a\u4f7f\u7528\u5b83\uff0cNginx\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u9ad8\u6027\u80fdHTTP\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u540c\u65f6\u5b83\u4e5f\u662f\u4e00\u4e2a\u901a\u7528\u7c7b\u578b\u7684\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u652f\u6301\u7edd\u5927\u90e8\u5206\u534f\u8bae\uff0c\u5982TCP\u3001UDP\u3001SMTP\u3001HTTPS\u7b49\u3002 Nginx\u4e0eRedis\u76f8\u540c\uff0c\u90fd\u662f\u57fa\u4e8e\u591a\u8def\u590d\u7528\u6a21\u578b\u6784\u5efa\u51fa\u7684\u4ea7\u7269\uff0c\u56e0\u6b64\u5b83\u4e0eRedis\u540c\u6837\u5177\u5907 \u300c\u300c\u8d44\u6e90\u5360\u7528\u5c11\u3001\u5e76\u53d1\u652f\u6301\u9ad8\u300d\u300d \u7684\u7279\u70b9\uff0c\u5728\u7406\u8bba\u4e0a\u5355\u8282\u70b9\u7684Nginx\u540c\u65f6\u652f\u63015W\u5e76\u53d1\u8fde\u63a5\uff0c\u800c\u5b9e\u9645\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u786c\u4ef6\u57fa\u7840\u5230\u4f4d\u518d\u7ed3\u5408\u7b80\u5355\u8c03\u4f18\u540e\u786e\u5b9e\u80fd\u8fbe\u5230\u8be5\u6570\u503c\u3002 \u5148\u6765\u770b\u770bNginx\u5f15\u5165\u524d\u540e\uff0c\u5ba2\u6237\u7aef\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b\u7684\u5bf9\u6bd4\uff1a \u539f\u672c\u5ba2\u6237\u7aef\u662f\u76f4\u63a5\u8bf7\u6c42\u76ee\u6807\u670d\u52a1\u5668\uff0c\u7531\u76ee\u6807\u670d\u52a1\u5668\u76f4\u63a5\u5b8c\u6210\u8bf7\u6c42\u5904\u7406\u5de5\u4f5c\uff0c\u4f46\u52a0\u5165Nginx\u540e\uff0c\u6240\u6709\u7684\u8bf7\u6c42\u4f1a\u5148\u7ecf\u8fc7Nginx\uff0c\u518d\u7531\u5176\u8fdb\u884c\u5206\u53d1\u5230\u5177\u4f53\u7684\u670d\u52a1\u5668\u5904\u7406\uff0c\u5904\u7406\u5b8c\u6210\u540e\u518d\u8fd4\u56deNginx\uff0c\u6700\u540e\u7531Nginx\u5c06\u6700\u7ec8\u7684\u54cd\u5e94\u7ed3\u679c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002 \u4e86\u89e3\u4e86Nginx\u7684\u57fa\u672c\u6982\u5ff5\u540e\uff0c\u518d\u6765\u5feb\u901f\u642d\u5efa\u4e00\u4e0b\u73af\u5883\uff0c\u4ee5\u53ca\u4e86\u89e3\u4e00\u4e9bNginx\u7684\u9ad8\u7ea7\u7279\u6027\uff0c\u5982\u52a8\u9759\u5206\u79bb\u3001\u8d44\u6e90\u538b\u7f29\u3001\u7f13\u5b58\u914d\u7f6e\u3001IP\u9ed1\u540d\u5355\u3001\u9ad8\u53ef\u7528\u4fdd\u969c\u7b49\u3002 \u4e8c\u3001Nginx\u73af\u5883\u642d\u5efa \u9996\u5148\u521b\u5efaNginx\u7684\u76ee\u5f55\u5e76\u8fdb\u5165\uff1a [root@localhost]#&nbsp;mkdir&nbsp;\/soft&nbsp;&amp;amp;&amp;amp;&nbsp;mkdir&nbsp;\/soft\/nginx\/&nbsp;&nbsp; [root@localhost]#&nbsp;cd&nbsp;\/soft\/nginx\/ \u767b\u5f55\u540e\u590d\u5236 \u4e0b\u8f7dNginx\u7684\u5b89\u88c5\u5305\uff0c\u53ef\u4ee5\u901a\u8fc7FTP\u5de5\u5177\u4e0a\u4f20\u79bb\u7ebf\u73af\u5883\u5305\uff0c\u4e5f\u53ef\u901a\u8fc7wget\u547d\u4ee4\u5728\u7ebf\u83b7\u53d6\u5b89\u88c5\u5305\uff1a [root@localhost]#&nbsp;wget&nbsp;https:\/\/nginx.org\/download\/nginx-1.21.6.tar.gz \u767b\u5f55\u540e\u590d\u5236 \u6ca1\u6709wget\u547d\u4ee4\u7684\u53ef\u901a\u8fc7yum\u547d\u4ee4\u5b89\u88c5\uff1a [root@localhost]#&nbsp;yum&nbsp;-y&nbsp;install&nbsp;wget \u767b\u5f55\u540e\u590d\u5236 \u89e3\u538bNginx\u7684\u538b\u7f29\u5305\uff1a [root@localhost]#&nbsp;tar&nbsp;-xvzf&nbsp;nginx-1.21.6.tar.gz \u767b\u5f55\u540e\u590d\u5236 \u4e0b\u8f7d\u5e76\u5b89\u88c5Nginx\u6240\u9700\u7684\u4f9d\u8d56\u5e93\u548c\u5305\uff1a [root@localhost]#&nbsp;yum&nbsp;install&nbsp;&#8211;downloadonly&nbsp;&#8211;downloaddir=\/soft\/nginx\/&nbsp;gcc-c++&nbsp;&nbsp; [root@localhost]#&nbsp;yum&nbsp;install&nbsp;&#8211;downloadonly&nbsp;&#8211;downloaddir=\/soft\/nginx\/&nbsp;pcre&nbsp;pcre-devel4&nbsp;&nbsp; [root@localhost]#&nbsp;yum&nbsp;install&nbsp;&#8211;downloadonly&nbsp;&#8211;downloaddir=\/soft\/nginx\/&nbsp;zlib&nbsp;zlib-devel&nbsp;&nbsp; [root@localhost]#&nbsp;yum&nbsp;install&nbsp;&#8211;downloadonly&nbsp;&#8211;downloaddir=\/soft\/nginx\/&nbsp;openssl&nbsp;openssl-devel \u767b\u5f55\u540e\u590d\u5236 \u4e5f\u53ef\u4ee5\u901a\u8fc7yum\u547d\u4ee4\u4e00\u952e\u4e0b\u8f7d\uff08\u63a8\u8350\u4e0a\u9762\u54ea\u79cd\u65b9\u5f0f\uff09\uff1a [root@localhost]#&nbsp;yum&nbsp;-y&nbsp;install&nbsp;gcc&nbsp;zlib&nbsp;zlib-devel&nbsp;pcre-devel&nbsp;openssl&nbsp;openssl-devel \u767b\u5f55\u540e\u590d\u5236 \u6267\u884c\u5b8c\u6210\u540e\uff0c\u7136\u540els\u67e5\u770b\u76ee\u5f55\u6587\u4ef6\uff0c\u4f1a\u770b\u4e00\u5927\u5806\u4f9d\u8d56\uff1a \u7d27\u63a5\u7740\u901a\u8fc7rpm\u547d\u4ee4\u4f9d\u6b21\u5c06\u4f9d\u8d56\u5305\u4e00\u4e2a\u4e2a\u6784\u5efa\uff0c\u6216\u8005\u901a\u8fc7\u5982\u4e0b\u6307\u4ee4\u4e00\u952e\u5b89\u88c5\u6240\u6709\u4f9d\u8d56\u5305\uff1a [root@localhost]#&nbsp;rpm&nbsp;-ivh&nbsp;&#8211;nodeps&nbsp;*.rpm \u767b\u5f55\u540e\u590d\u5236 \u8fdb\u5165\u89e3\u538b\u540e\u7684\u76ee\u5f55\uff0c\u7136\u540e\u6267\u884cNginx\u7684\u914d\u7f6e\u811a\u672c\uff0c\u4e3a\u540e\u7eed\u7684\u5b89\u88c5\u63d0\u524d\u914d\u7f6e\u597d\u73af\u5883\uff0c\u9ed8\u8ba4\u4f4d\u4e8e\/usr\/local\/nginx\/\u76ee\u5f55\u4e0b\uff08\u53ef\u81ea\u5b9a\u4e49\u76ee\u5f55\uff09\uff1a [root@localhost]#&nbsp;cd&nbsp;nginx-1.21.6&nbsp;&nbsp; [root@localhost]#&nbsp;.\/configure&nbsp;&#8211;prefix=\/soft\/nginx\/ \u767b\u5f55\u540e\u590d\u5236 \u7f16\u8bd1\u5e76\u5b89\u88c5Nginx\uff1a [&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-62348","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/62348","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=62348"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/62348\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=62348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=62348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=62348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}