{"id":5805,"date":"2017-07-03T17:58:31","date_gmt":"2017-07-03T09:58:31","guid":{"rendered":"https:\/\/sdeno.com\/?p=5805"},"modified":"2017-07-03T19:22:45","modified_gmt":"2017-07-03T11:22:45","slug":"%e5%85%a8%e9%9d%a2%e4%ba%86%e8%a7%a3-nginx-%e4%b8%bb%e8%a6%81%e5%ba%94%e7%94%a8%e5%9c%ba%e6%99%af","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=5805","title":{"rendered":"\u5168\u9762\u4e86\u89e3 Nginx \u4e3b\u8981\u5e94\u7528\u573a\u666f"},"content":{"rendered":"<figure class=\"mdx-lazyload-container\" style=\"max-width:440px\"><div style=\"padding-top:57.272727272727%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"440\" height=\"252\" class=\"alignnone size-full wp-image-5807 lazyload\" title=\"nginx_icon\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2017\/07\/nginx_icon.jpg\" alt=\"nginx_icon\"><\/figure>\n<p>nginx \u7b14\u8bb0 \u63a8\u8350<\/p>\n<p><span style=\"color: #3e3e3e;\">\u672c\u6587\u53ea\u9488\u5bf9Nginx\u5728\u4e0d\u52a0\u8f7d\u7b2c\u4e09\u65b9\u6a21\u5757\u7684\u60c5\u51b5\u80fd\u5904\u7406\u54ea\u4e9b\u4e8b\u60c5\uff0c\u7531\u4e8e\u7b2c\u4e09\u65b9\u6a21\u5757\u592a\u591a\u6240\u4ee5\u4e5f\u4ecb\u7ecd\u4e0d\u5b8c\uff0c\u5f53\u7136\u672c\u6587\u672c\u8eab\u4e5f\u53ef\u80fd\u4ecb\u7ecd\u7684\u4e0d\u5b8c\u6574\uff0c\u6bd5\u7adf\u53ea\u662f\u6211\u4e2a\u4eba\u4f7f\u7528\u8fc7\u548c\u4e86\u89e3\u5230\u8fc7\u5f97\u3002\u6240\u4ee5\u8fd8\u8bf7\u89c1\u8c05\uff0c\u540c\u65f6\u6b22\u8fce\u7559\u8a00\u4ea4\u6d41<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #ab1942;\">Nginx\u80fd\u505a\u4ec0\u4e48<\/strong><\/p>\n<p style=\"color: #3e3e3e;\">1.\u53cd\u5411\u4ee3\u7406<\/p>\n<p style=\"color: #3e3e3e;\">2.\u8d1f\u8f7d\u5747\u8861<\/p>\n<p style=\"color: #3e3e3e;\">3.HTTP\u670d\u52a1\u5668\uff08\u5305\u542b\u52a8\u9759\u5206\u79bb\uff09<\/p>\n<p style=\"color: #3e3e3e;\">4.\u6b63\u5411\u4ee3\u7406<\/p>\n<p style=\"color: #3e3e3e;\">\u4ee5\u4e0a\u5c31\u662f\u6211\u4e86\u89e3\u5230\u7684Nginx\u5728\u4e0d\u4f9d\u8d56\u7b2c\u4e09\u65b9\u6a21\u5757\u80fd\u5904\u7406\u7684\u4e8b\u60c5\uff0c\u4e0b\u9762\u8be6\u7ec6\u8bf4\u660e\u6bcf\u79cd\u529f\u80fd\u600e\u4e48\u505a<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #ab1942;\">\u53cd\u5411\u4ee3\u7406<\/strong><\/p>\n<p>\u6548\u679c\uff1a\u4e00\u4e2a\u670d\u52a1\u5668\u4e0a\u5c31\u4e00\u4e2a80\u7aef\u53e3\uff0c\u4f46\u662f\u670d\u52a1\u5668\u4e0a\u60f3\u642d\u5efa\u591a\u4e2a\u7f51\u7ad9\uff0c\u60f3\u8981\u5b9e\u73b0\u8bbf\u95ee\u57df\u540d\u5c31\u80fd\u76f4\u63a5\u8bbf\u95ee\u4e0d\u540c\u7f51\u7ad9\u5e76\u4e14\u90fd\u662f\u901a\u8fc780\u7aef\u53e3\u8bbf\u95ee\u7684\u8bdd\uff0c\u5c31\u4f7f\u7528nginx\u53cd\u5411\u4ee3\u7406\u7684\u529f\u80fd\u5c31\u5408\u9002\u4e86\u3002<\/p>\n<pre>server { \r\n listen 80; \r\n server_name localhost; \r\n client_max_body_size 1024M;\r\n \r\n location \/ {\r\n proxy_pass http:\/\/localhost:8080;\r\n proxy_set_header Host $host:$server_port;\r\n }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #ab1942;\">\u8d1f\u8f7d\u5747\u8861<\/strong><\/p>\n<p>\u8d1f\u8f7d\u5747\u8861\u4e5f\u662fNginx\u5e38\u7528\u7684\u4e00\u4e2a\u529f\u80fd\uff0c\u8d1f\u8f7d\u5747\u8861\u5176\u610f\u601d\u5c31\u662f\u5206\u644a\u5230\u591a\u4e2a\u64cd\u4f5c\u5355\u5143\u4e0a\u8fdb\u884c\u6267\u884c\uff0c\u4f8b\u5982Web\u670d\u52a1\u5668\u3001FTP\u670d\u52a1\u5668\u3001\u4f01\u4e1a\u5173\u952e\u5e94\u7528\u670d\u52a1\u5668\u548c\u5176\u5b83\u5173\u952e\u4efb\u52a1\u670d\u52a1\u5668\u7b49\uff0c\u4ece\u800c\u5171\u540c\u5b8c\u6210\u5de5\u4f5c\u4efb\u52a1\u3002\u7b80\u5355\u800c\u8a00\u5c31\u662f\u5f53\u67092\u53f0\u6216\u4ee5\u4e0a\u670d\u52a1\u5668\u65f6\uff0c\u6839\u636e\u89c4\u5219\u968f\u673a\u7684\u5c06\u8bf7\u6c42\u5206\u53d1\u5230\u6307\u5b9a\u7684\u670d\u52a1\u5668\u4e0a\u5904\u7406\uff0c\u8d1f\u8f7d\u5747\u8861\u914d\u7f6e\u4e00\u822c\u90fd\u9700\u8981\u540c\u65f6\u914d\u7f6e\u53cd\u5411\u4ee3\u7406\uff0c\u901a\u8fc7\u53cd\u5411\u4ee3\u7406\u8df3\u8f6c\u5230\u8d1f\u8f7d\u5747\u8861\u3002\u800cNginx\u76ee\u524d\u652f\u6301\u81ea\u5e263\u79cd\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\uff0c\u8fd8\u67092\u79cd\u5e38\u7528\u7684\u7b2c\u4e09\u65b9\u7b56\u7565\u3002<\/p>\n<p><strong style=\"color: #3e3e3e;\">1\u3001RR\uff08\u9ed8\u8ba4\uff09<\/strong><\/p>\n<p><span style=\"color: #3e3e3e;\">\u6bcf\u4e2a\u8bf7\u6c42\u6309\u65f6\u95f4\u987a\u5e8f\u9010\u4e00\u5206\u914d\u5230\u4e0d\u540c\u7684\u540e\u7aef\u670d\u52a1\u5668\uff0c\u5982\u679c\u540e\u7aef\u670d\u52a1\u5668down\u6389\uff0c\u80fd\u81ea\u52a8\u5254\u9664\u3002<\/span><\/p>\n<pre>upstream test {\r\n server localhost:8080;\r\n server localhost:8081;\r\n}\r\n\r\nserver {\r\n   listen 81; \r\n   server_name localhost; \r\n   client_max_body_size 1024M;\r\n \r\n   location \/ {\r\n     proxy_pass http:\/\/test;\r\n     proxy_set_header Host $host:$server_port;\r\n   }\r\n}<\/pre>\n<p>\u8fd9\u91cc\u6211\u914d\u7f6e\u4e862\u53f0\u670d\u52a1\u5668\uff0c\u5f53\u7136\u5b9e\u9645\u4e0a\u662f\u4e00\u53f0\uff0c\u53ea\u662f\u7aef\u53e3\u4e0d\u4e00\u6837\u800c\u5df2\uff0c\u800c8081\u7684\u670d\u52a1\u5668\u662f\u4e0d\u5b58\u5728\u7684,\u4e5f\u5c31\u662f\u8bf4\u8bbf\u95ee\u4e0d\u5230\uff0c\u4f46\u662f\u6211\u4eec\u8bbf\u95eehttp:\/\/localhost \u7684\u65f6\u5019,\u4e5f\u4e0d\u4f1a\u6709\u95ee\u9898\uff0c\u4f1a\u9ed8\u8ba4\u8df3\u8f6c\u5230http:\/\/localhost:8080 \u5177\u4f53\u662f\u56e0\u4e3aNginx\u4f1a\u81ea\u52a8\u5224\u65ad\u670d\u52a1\u5668\u7684\u72b6\u6001\uff0c\u5982\u679c\u670d\u52a1\u5668\u5904\u4e8e\u4e0d\u80fd\u8bbf\u95ee\uff08\u670d\u52a1\u5668\u6302\u4e86\uff09\uff0c\u5c31\u4e0d\u4f1a\u8df3\u8f6c\u5230\u8fd9\u53f0\u670d\u52a1\u5668\uff0c\u6240\u4ee5\u4e5f\u907f\u514d\u4e86\u4e00\u53f0\u670d\u52a1\u5668\u6302\u4e86\u5f71\u54cd\u4f7f\u7528\u7684\u60c5\u51b5\uff0c\u7531\u4e8eNginx\u9ed8\u8ba4\u662fRR\u7b56\u7565\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u9700\u8981\u5176\u4ed6\u66f4\u591a\u7684\u8bbe\u7f6e\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #3e3e3e;\">2\u3001\u6743\u91cd \uff08\u5206\u914d\u6982\u7387\uff09<\/strong><\/p>\n<pre>upstream test {\r\n server localhost:8080 weight=9;\r\n server localhost:8081 weight=1;\r\n}<\/pre>\n<p>\u90a3\u4e4810\u6b21\u4e00\u822c\u53ea\u4f1a\u67091\u6b21\u4f1a\u8bbf\u95ee\u52308081\uff0c\u800c\u67099\u6b21\u4f1a\u8bbf\u95ee\u52308080<\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #3e3e3e;\">3\u3001ip_hash<\/strong><\/p>\n<p>\u5982\u679c\u4e00\u4e2a\u5ba2\u6237\u7b2c\u4e00\u6b21\u767b\u9646\u67d0\u53f0\u670d\u52a1\u5668\u4e2d\u5c31\u4fdd\u5b58\u4e86session\u7684\u767b\u9646\u4fe1\u606f\u5728\u8fd9\u53f0\u670d\u52a1\u5668\u4e2d\uff0c\u4e07\u4e00\u4e0b\u6b21\u5206\u914d\u5230\u522b\u7684\u670d\u52a1\u5668\u5c31\u9700\u8981\u91cd\u65b0\u767b\u9646\u4e0d\u662f\u5f88\u9ebb\u70e6\u5417\uff1f\u6240\u4ee5\u5c31\u9700\u8981ip_hash\uff0c\u5982\u679c\u8be5\u5ba2\u6237\u7b2c\u4e00\u6b21\u628asession\u4fdd\u5b58\u5230\u4e86\u8be5\u670d\u52a1\u5668\u4ee5\u540e\u5c31\u4e00\u76f4\u8bbf\u95ee\u8be5\u670d\u52a1\u5668\uff0c\u5c31\u4e0d\u9700\u8981\u91cd\u65b0\u767b\u9646\u4e86\u3002\u6240\u4ee5\u5f88\u591a\u65f6\u5019\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u5ba2\u6237\u53ea\u8bbf\u95ee\u4e00\u4e2a\u670d\u52a1\u5668\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u7528iphash\u4e86\uff0ciphash\u7684\u6bcf\u4e2a\u8bf7\u6c42\u6309\u8bbf\u95eeip\u7684hash\u7ed3\u679c\u5206\u914d\uff0c\u8fd9\u6837\u6bcf\u4e2a\u8bbf\u5ba2\u56fa\u5b9a\u8bbf\u95ee\u4e00\u4e2a\u540e\u7aef\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u89e3\u51b3session\u7684\u95ee\u9898\u3002<\/p>\n<pre>upstream test {\r\n ip_hash;\r\n server localhost:8080;\r\n server localhost:8081;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #3e3e3e;\">4\u3001fair\uff08\u7b2c\u4e09\u65b9\uff09<\/strong><\/p>\n<p>\u6309\u540e\u7aef\u670d\u52a1\u5668\u7684\u54cd\u5e94\u65f6\u95f4\u6765\u5206\u914d\u8bf7\u6c42\uff0c\u54cd\u5e94\u65f6\u95f4\u77ed\u7684\u4f18\u5148\u5206\u914d\uff0c\u54ea\u53f0\u670d\u52a1\u5668\u8fd0\u884c\u5feb\u5c31\u5148\u5206\u914d\u7ed9\u54ea\u53f0\u670d\u52a1\u5668\u3002<\/p>\n<pre>upstream backend {\r\n fair;\r\n server localhost:8080;\r\n server localhost:8081;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #3e3e3e;\">5\u3001url_hash\uff08\u7b2c\u4e09\u65b9\uff09<\/strong><\/p>\n<p>\u6309\u8bbf\u95eeurl\u7684hash\u7ed3\u679c\u6765\u5206\u914d\u8bf7\u6c42\uff0c\u4f7f\u6bcf\u4e2aurl\u5b9a\u5411\u5230\u540c\u4e00\u4e2a\u540e\u7aef\u670d\u52a1\u5668\uff0c\u540e\u7aef\u670d\u52a1\u5668\u4e3a\u7f13\u5b58\u65f6\u6bd4\u8f83\u6709\u6548\u3002 \u5728upstream\u4e2d\u52a0\u5165hash\u8bed\u53e5\uff0cserver\u8bed\u53e5\u4e2d\u4e0d\u80fd\u5199\u5165weight\u7b49\u5176\u4ed6\u7684\u53c2\u6570\uff0chash_method\u662f\u4f7f\u7528\u7684hash\u7b97\u6cd5<\/p>\n<pre>upstream backend {\r\n hash $request_uri;\r\n hash_method crc32;\r\n server localhost:8080;\r\n server localhost:8081;\r\n}<\/pre>\n<p>\u4ee5\u4e0a5\u79cd\u8d1f\u8f7d\u5747\u8861\u5404\u81ea\u9002\u7528\u4e0d\u540c\u60c5\u51b5\u4e0b\u4f7f\u7528\uff0c\u6240\u4ee5\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u9009\u62e9\u4f7f\u7528\u54ea\u79cd\u7b56\u7565\u6a21\u5f0f,\u4e0d\u8fc7fair\u548curl_hash\u9700\u8981\u5b89\u88c5\u7b2c\u4e09\u65b9\u6a21\u5757\u624d\u80fd\u4f7f\u7528\uff0c\u7531\u4e8e\u672c\u6587\u4e3b\u8981\u4ecb\u7ecdNginx\u80fd\u505a\u7684\u4e8b\u60c5\uff0c\u6240\u4ee5Nginx\u5b89\u88c5\u7b2c\u4e09\u65b9\u6a21\u5757\u4e0d\u4f1a\u518d\u672c\u6587\u4ecb\u7ecd<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #ab1942;\">HTTP\u670d\u52a1\u5668<\/strong><\/p>\n<p>Nginx\u672c\u8eab\u4e5f\u662f\u4e00\u4e2a\u9759\u6001\u8d44\u6e90\u7684\u670d\u52a1\u5668\uff0c\u5f53\u53ea\u6709\u9759\u6001\u8d44\u6e90\u7684\u65f6\u5019\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528Nginx\u6765\u505a\u670d\u52a1\u5668\uff0c\u540c\u65f6\u73b0\u5728\u4e5f\u5f88\u6d41\u884c\u52a8\u9759\u5206\u79bb\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7Nginx\u6765\u5b9e\u73b0\uff0c\u9996\u5148\u770b\u770bNginx\u505a\u9759\u6001\u8d44\u6e90\u670d\u52a1\u5668<\/p>\n<pre>server {\r\n listen 80; \r\n server_name localhost; \r\n client_max_body_size 1024M;\r\n \r\n \r\n location \/ {\r\n   root e:wwwroot;\r\n   index index.html;\r\n }\r\n}<\/pre>\n<p>\u8fd9\u6837\u5982\u679c\u8bbf\u95eehttp:\/\/localhost \u5c31\u4f1a\u9ed8\u8ba4\u8bbf\u95ee\u5230E\u76d8wwwroot\u76ee\u5f55\u4e0b\u9762\u7684index.html\uff0c\u5982\u679c\u4e00\u4e2a\u7f51\u7ad9\u53ea\u662f\u9759\u6001\u9875\u9762\u7684\u8bdd\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u6765\u5b9e\u73b0\u90e8\u7f72\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #ab1942;\">\u52a8\u9759\u5206\u79bb<\/strong><\/p>\n<p>\u52a8\u9759\u5206\u79bb\u662f\u8ba9\u52a8\u6001\u7f51\u7ad9\u91cc\u7684\u52a8\u6001\u7f51\u9875\u6839\u636e\u4e00\u5b9a\u89c4\u5219\u628a\u4e0d\u53d8\u7684\u8d44\u6e90\u548c\u7ecf\u5e38\u53d8\u7684\u8d44\u6e90\u533a\u5206\u5f00\u6765\uff0c\u52a8\u9759\u8d44\u6e90\u505a\u597d\u4e86\u62c6\u5206\u4ee5\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6839\u636e\u9759\u6001\u8d44\u6e90\u7684\u7279\u70b9\u5c06\u5176\u505a\u7f13\u5b58\u64cd\u4f5c\uff0c\u8fd9\u5c31\u662f\u7f51\u7ad9\u9759\u6001\u5316\u5904\u7406\u7684\u6838\u5fc3\u601d\u8def<\/p>\n<pre>upstream test{ \r\n server localhost:8080; \r\n server localhost:8081; \r\n} \r\n \r\nserver { \r\n listen 80; \r\n server_name localhost; \r\n \r\n location \/ { \r\n   root e:wwwroot; \r\n   index index.html; \r\n } \r\n \r\n # \u6240\u6709\u9759\u6001\u8bf7\u6c42\u90fd\u7531nginx\u5904\u7406\uff0c\u5b58\u653e\u76ee\u5f55\u4e3ahtml \r\n location ~ .(gif|jpg|jpeg|png|bmp|swf|css|js)$ { \r\n   root e:wwwroot; \r\n } \r\n \r\n # \u6240\u6709\u52a8\u6001\u8bf7\u6c42\u90fd\u8f6c\u53d1\u7ed9tomcat\u5904\u7406 \r\n location ~ .(jsp|do)$ { \r\n   proxy_pass http:\/\/test; \r\n } \r\n \r\n error_page 500 502 503 504 \/50x.html; \r\n location = \/50x.html { \r\n   root e:wwwroot; \r\n } \r\n}<\/pre>\n<p>\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5427HTML\u4ee5\u53ca\u56fe\u7247\u548ccss\u4ee5\u53cajs\u653e\u5230wwwroot\u76ee\u5f55\u4e0b\uff0c\u800ctomcat\u53ea\u8d1f\u8d23\u5904\u7406jsp\u548c\u8bf7\u6c42\uff0c\u4f8b\u5982\u5f53\u6211\u4eec\u540e\u7f00\u4e3agif\u7684\u65f6\u5019\uff0cNginx\u9ed8\u8ba4\u4f1a\u4ecewwwroot\u83b7\u53d6\u5230\u5f53\u524d\u8bf7\u6c42\u7684\u52a8\u6001\u56fe\u6587\u4ef6\u8fd4\u56de\uff0c\u5f53\u7136\u8fd9\u91cc\u7684\u9759\u6001\u6587\u4ef6\u8ddfNginx\u662f\u540c\u4e00\u53f0\u670d\u52a1\u5668\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728\u53e6\u5916\u4e00\u53f0\u670d\u52a1\u5668\uff0c\u7136\u540e\u901a\u8fc7\u53cd\u5411\u4ee3\u7406\u548c\u8d1f\u8f7d\u5747\u8861\u914d\u7f6e\u8fc7\u53bb\u5c31\u597d\u4e86\uff0c\u53ea\u8981\u641e\u6e05\u695a\u4e86\u6700\u57fa\u672c\u7684\u6d41\u7a0b\uff0c\u5f88\u591a\u914d\u7f6e\u5c31\u5f88\u7b80\u5355\u4e86\uff0c\u53e6\u5916localtion\u540e\u9762\u5176\u5b9e\u662f\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u6240\u4ee5\u975e\u5e38\u7075\u6d3b<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong style=\"color: #ab1942;\">\u6b63\u5411\u4ee3\u7406<\/strong><\/p>\n<p>\u6b63\u5411\u4ee3\u7406\uff0c\u610f\u601d\u662f\u4e00\u4e2a\u4f4d\u4e8e\u5ba2\u6237\u7aef\u548c\u539f\u59cb\u670d\u52a1\u5668(origin server)\u4e4b\u95f4\u7684\u670d\u52a1\u5668\uff0c\u4e3a\u4e86\u4ece\u539f\u59cb\u670d\u52a1\u5668\u53d6\u5f97\u5185\u5bb9\uff0c\u5ba2\u6237\u7aef\u5411\u4ee3\u7406\u53d1\u9001\u4e00\u4e2a\u8bf7\u6c42\u5e76\u6307\u5b9a\u76ee\u6807(\u539f\u59cb\u670d\u52a1\u5668)\uff0c\u7136\u540e\u4ee3\u7406\u5411\u539f\u59cb\u670d\u52a1\u5668\u8f6c\u4ea4\u8bf7\u6c42\u5e76\u5c06\u83b7\u5f97\u7684\u5185\u5bb9\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002\u5ba2\u6237\u7aef\u624d\u80fd\u4f7f\u7528\u6b63\u5411\u4ee3\u7406\u3002\u5f53\u4f60\u9700\u8981\u628a\u4f60\u7684\u670d\u52a1\u5668\u4f5c\u4e3a\u4ee3\u7406\u670d\u52a1\u5668\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u7528Nginx\u6765\u5b9e\u73b0\u6b63\u5411\u4ee3\u7406\uff0c\u4f46\u662f\u76ee\u524dNginx\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u90a3\u4e48\u5c31\u662f\u4e0d\u652f\u6301HTTPS\uff0c\u867d\u7136\u6211\u767e\u5ea6\u5230\u8fc7\u914d\u7f6eHTTPS\u7684\u6b63\u5411\u4ee3\u7406\uff0c\u4f46\u662f\u5230\u6700\u540e\u53d1\u73b0\u8fd8\u662f\u4ee3\u7406\u4e0d\u4e86\uff0c\u5f53\u7136\u53ef\u80fd\u662f\u6211\u914d\u7f6e\u7684\u4e0d\u5bf9\uff0c\u6240\u4ee5\u4e5f\u5e0c\u671b\u6709\u77e5\u9053\u6b63\u786e\u65b9\u6cd5\u7684\u540c\u5fd7\u4eec\u7559\u8a00\u8bf4\u660e\u4e00\u4e0b\u3002<\/p>\n<pre>resolver 114.114.114.114 8.8.8.8;\r\nserver {\r\n \r\n  resolver_timeout 5s;\r\n \r\n  listen 81;\r\n \r\n  access_log e:wwwrootproxy.access.log;\r\n  error_log e:wwwrootproxy.error.log;\r\n \r\n location \/ {\r\n   proxy_pass http:\/\/$host$request_uri;\r\n }\r\n}<\/pre>\n<p>resolver\u662f\u914d\u7f6e\u6b63\u5411\u4ee3\u7406\u7684DNS\u670d\u52a1\u5668\uff0clisten \u662f\u6b63\u5411\u4ee3\u7406\u7684\u7aef\u53e3\uff0c\u914d\u7f6e\u597d\u4e86\u5c31\u53ef\u4ee5\u5728ie\u4e0a\u9762\u6216\u8005\u5176\u4ed6\u4ee3\u7406\u63d2\u4ef6\u4e0a\u9762\u4f7f\u7528\u670d\u52a1\u5668ip+\u7aef\u53e3\u53f7\u8fdb\u884c\u4ee3\u7406\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #993300;\">\u6301\u70ed\u542f\u52a8<\/span><\/p>\n<p>Nginx\u662f\u652f\u6301\u70ed\u542f\u52a8\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\u5f53\u6211\u4eec\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u540e\uff0c\u4e0d\u7528\u5173\u95edNginx\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u8ba9\u914d\u7f6e\u751f\u6548\uff0c\u5f53\u7136\u6211\u5e76\u4e0d\u77e5\u9053\u591a\u5c11\u4eba\u77e5\u9053\u8fd9\u4e2a\uff0c\u53cd\u6b63\u6211\u4e00\u5f00\u59cb\u5e76\u4e0d\u77e5\u9053\uff0c\u5bfc\u81f4\u7ecf\u5e38\u6740\u6b7b\u4e86Nginx\u7ebf\u7a0b\u518d\u6765\u542f\u52a8\u3002\u3002\u3002Nginx\u4ece\u65b0\u8bfb\u53d6\u914d\u7f6e\u7684\u547d\u4ee4\u662f<\/p>\n<pre>nginx -s reload<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nginx \u7b14\u8bb0 \u63a8\u8350 \u672c\u6587\u53ea\u9488\u5bf9Nginx\u5728\u4e0d\u52a0\u8f7d\u7b2c\u4e09\u65b9\u6a21\u5757\u7684\u60c5\u51b5\u80fd\u5904\u7406\u54ea\u4e9b\u4e8b\u60c5\uff0c\u7531\u4e8e\u7b2c\u4e09\u65b9\u6a21\u5757\u592a\u591a\u6240\u4ee5\u4e5f\u4ecb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-5805","post","type-post","status-publish","format-standard","hentry","category-9"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5805"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5805\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}