{"id":26,"date":"2021-06-22T22:35:51","date_gmt":"2021-06-22T14:35:51","guid":{"rendered":"http:\/\/www.tysql.com\/?p=26"},"modified":"2021-06-22T22:35:51","modified_gmt":"2021-06-22T14:35:51","slug":"nginx%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1","status":"publish","type":"post","link":"https:\/\/www.tysql.com\/index.php\/2021\/06\/22\/nginx%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1\/","title":{"rendered":"Nginx\u8d1f\u8f7d\u5747\u8861"},"content":{"rendered":"\n<p>\u4e00\u3001\u5173\u4e8eNginx\u7684\u8d1f\u8f7d\u5747\u8861<\/p>\n\n\n\n<p>\u5728\u670d\u52a1\u5668\u96c6\u7fa4\u4e2d\uff0cNginx\u8d77\u5230\u4e00\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\u7684\u89d2\u8272\uff08\u5373\u53cd\u5411\u4ee3\u7406\uff09\uff0c\u4e3a\u4e86\u907f\u514d\u5355\u72ec\u4e00\u4e2a\u670d\u52a1\u5668\u538b\u529b\u8fc7\u5927\uff0c\u5c06\u6765\u81ea\u7528\u6237\u7684\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u4e0d\u540c\u7684\u670d\u52a1\u5668\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001Nginx\u8d1f\u8f7d\u5747\u8861\u7b56\u7565<\/h2>\n\n\n\n<p>\u8d1f\u8f7d\u5747\u8861\u7528\u4e8e\u4ece\u201cupstream\u201d\u6a21\u5757\u5b9a\u4e49\u7684\u540e\u7aef\u670d\u52a1\u5668\u5217\u8868\u4e2d\u9009\u53d6\u4e00\u53f0\u670d\u52a1\u5668\u63a5\u53d7\u7528\u6237\u7684\u8bf7\u6c42\u3002\u4e00\u4e2a\u6700\u57fa\u672c\u7684upstream\u6a21\u5757\u662f\u8fd9\u6837\u7684\uff0c\u6a21\u5757\u5185\u7684server\u662f\u670d\u52a1\u5668\u5217\u8868\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">#\u52a8\u6001\u670d\u52a1\u5668\u7ec4\n    upstream dynamic_zuoyu {\n        server localhost:8080;  #tomcat 7.0\n        server localhost:8081;  #tomcat 8.0\n        server localhost:8082;  #tomcat 8.5\n        server localhost:8083;  #tomcat 9.0\n    }<\/pre><\/div>\n\n\n\n<p>\u5728upstream\u6a21\u5757\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u8981\u8ba9\u6307\u5b9a\u7684\u8bbf\u95ee\u53cd\u5411\u4ee3\u7406\u5230\u670d\u52a1\u5668\u5217\u8868\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">#\u5176\u4ed6\u9875\u9762\u53cd\u5411\u4ee3\u7406\u5230tomcat\u5bb9\u5668\n        location ~ .*$ {\n            index index.jsp index.html;\n            proxy_pass http:\/\/dynamic_zuoyu;\n        }<\/pre><\/div>\n\n\n\n<p>\u4e00\u4e2a\u5b8c\u6574\u7684nginx.conf\u793a\u4f8b<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">#user  nobody;\nworker_processes  1;\n\nevents {\n    worker_connections  1024;\n}\n\n\n\nhttp {\n    include       mime.types;\n    default_type  application\/octet-stream;\n\n    #\u52a8\u6001\u670d\u52a1\u5668\u7ec4(balancing_name\u8fd9\u4e2a\u540d\u5b57\u968f\u4fbf\u8d77,\u548c\u4e0b\u9762\u7684\u5bf9\u5e94\u4e0a\u5c31\u884c)\n    #weight\u6743\u91cd\u53ef\u81ea\u884c\u4fee\u6539\n\n    upstream balancing_name {\n        server a.tylove.top weight=1;  #\u670d\u52a1\u56681\u7684\u5730\u5740\n        server 10.10.10.185:8080 weight=1;  #\u670d\u52a1\u56682\u7684\u5730\u5740\n    }\n    server {\n        listen       80;\n        server_name  localhost;\n\n        #charset koi8-r;\n\n        #access_log  logs\/host.access.log  main;\n\n       \n\t\n        location \/ {\n            root   html;\n            index  index.html index.htm;\n            proxy_set_header Host $host; #\u540e\u7aef\u7684Web\u670d\u52a1\u5668\u53ef\u4ee5\u901a\u8fc7X-Forwarded-For\u83b7\u53d6\u7528\u6237\u771f\u5b9eIP \n            proxy_pass http:\/\/balancing_name;\n        }\n\t\t\n        #error_page  404              \/404.html;\n\t\t\n        # redirect server error pages to the static page \/50x.html\n        #\n        error_page   500 502 503 504  \/50x.html;\n        location = \/50x.html {\n            root   html;\n        }\n\n       \n    }\n\n    # HTTPS server\n    #\n    #server {\n    #    listen       443 ssl;\n    #    server_name  localhost;\n\n    #    ssl_certificate      cert.pem;\n    #    ssl_certificate_key  cert.key;\n\n    #    ssl_session_cache    shared:SSL:1m;\n    #    ssl_session_timeout  5m;\n\n    #    ssl_ciphers  HIGH:!aNULL:!MD5;\n    #    ssl_prefer_server_ciphers  on;\n\n    #    location \/ {\n    #        root   html;\n    #        index  index.html index.htm;\n    #    }\n    #}\n    \n\n}<\/pre><\/div>\n\n\n\n<p>\u4e0b\u9762\u8fd9\u4e00\u53e5\u4e0d\u52a0\u4f1a\u62a5<a rel=\"noreferrer noopener\" href=\"https:\/\/my.oschina.net\/u\/4302576\/blog\/4045739\" target=\"_blank\">400 bad request<\/a>\u00a0\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48,\u5728\u4e0a\u9762\u768435\u884c<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">proxy_set_header Host $host; #\u540e\u7aef\u7684Web\u670d\u52a1\u5668\u53ef\u4ee5\u901a\u8fc7X-Forwarded-For\u83b7\u53d6\u7528\u6237\u771f\u5b9eIP <\/pre><\/div>\n\n\n\n<p>\u8fd9\u5c31\u662f\u6700\u57fa\u672c\u7684\u8d1f\u8f7d\u5747\u8861\u5b9e\u4f8b\uff0c\u4f46\u8fd9\u4e0d\u8db3\u4ee5\u6ee1\u8db3\u5b9e\u9645\u9700\u6c42\uff1b\u76ee\u524dNginx\u670d\u52a1\u5668\u7684upstream\u6a21\u5757\u652f\u63016\u79cd\u65b9\u5f0f\u7684\u5206\u914d\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"438\" height=\"390\" src=\"http:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image-1-1.png\" alt=\"\" class=\"wp-image-28\" srcset=\"https:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image-1-1.png 438w, https:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image-1-1-300x267.png 300w\" sizes=\"auto, (max-width: 438px) 100vw, 438px\" \/><\/figure>\n\n\n\n<p>\u5728\u8fd9\u91cc\uff0c\u53ea\u8be6\u7ec6\u8bf4\u660eNginx\u81ea\u5e26\u7684\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\uff0c\u7b2c\u4e09\u65b9\u4e0d\u591a\u63cf\u8ff0\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1\u3001\u8f6e\u8be2<\/h2>\n\n\n\n<p>\u6700\u57fa\u672c\u7684\u914d\u7f6e\u65b9\u6cd5\uff0c\u4e0a\u9762\u7684\u4f8b\u5b50\u5c31\u662f\u8f6e\u8be2\u7684\u65b9\u5f0f\uff0c\u5b83\u662fupstream\u6a21\u5757\u9ed8\u8ba4\u7684\u8d1f\u8f7d\u5747\u8861\u9ed8\u8ba4\u7b56\u7565\u3002\u6bcf\u4e2a\u8bf7\u6c42\u4f1a\u6309\u65f6\u95f4\u987a\u5e8f\u9010\u4e00\u5206\u914d\u5230\u4e0d\u540c\u7684\u540e\u7aef\u670d\u52a1\u5668\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"441\" src=\"http:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image-3-768x441-1.png\" alt=\"\" class=\"wp-image-29\" srcset=\"https:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image-3-768x441-1.png 768w, https:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image-3-768x441-1-300x172.png 300w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5728\u8f6e\u8be2\u4e2d\uff0c\u5982\u679c\u670d\u52a1\u5668down\u6389\u4e86\uff0c\u4f1a\u81ea\u52a8\u5254\u9664\u8be5\u670d\u52a1\u5668\u3002<\/li><li>\u7f3a\u7701\u914d\u7f6e\u5c31\u662f\u8f6e\u8be2\u7b56\u7565\u3002<\/li><li>\u6b64\u7b56\u7565\u9002\u5408\u670d\u52a1\u5668\u914d\u7f6e\u76f8\u5f53\uff0c\u65e0\u72b6\u6001\u4e14\u77ed\u5e73\u5feb\u7684\u670d\u52a1\u4f7f\u7528\u3002<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2\u3001weight\u6743\u91cd<\/h2>\n\n\n\n<p>\u6743\u91cd\u65b9\u5f0f\uff0c\u5728\u8f6e\u8be2\u7b56\u7565\u7684\u57fa\u7840\u4e0a\u6307\u5b9a\u8f6e\u8be2\u7684\u51e0\u7387\u3002\u4f8b\u5b50\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">#\u52a8\u6001\u670d\u52a1\u5668\u7ec4\n    upstream dynamic_zuoyu {\n        server localhost:8080   weight=2;  #tomcat 7.0\n        server localhost:8081;  #tomcat 8.0\n        server localhost:8082   backup;  #tomcat 8.5\n        server localhost:8083   max_fails=3 fail_timeout=20s;  #tomcat 9.0\n    }<\/pre><\/div>\n\n\n\n<p>\u5728\u8be5\u4f8b\u5b50\u4e2d\uff0cweight\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u8f6e\u8be2\u51e0\u7387\uff0cweight\u7684\u9ed8\u8ba4\u503c\u4e3a1,\uff1bweight\u7684\u6570\u503c\u4e0e\u8bbf\u95ee\u6bd4\u7387\u6210\u6b63\u6bd4\uff0c\u6bd4\u5982Tomcat 7.0\u88ab\u8bbf\u95ee\u7684\u51e0\u7387\u4e3a\u5176\u4ed6\u670d\u52a1\u5668\u7684\u4e24\u500d\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u6743\u91cd\u8d8a\u9ad8\u5206\u914d\u5230\u9700\u8981\u5904\u7406\u7684\u8bf7\u6c42\u8d8a\u591a\u3002<\/li><li>\u6b64\u7b56\u7565\u53ef\u4ee5\u4e0eleast_conn\u548cip_hash\u7ed3\u5408\u4f7f\u7528\u3002<\/li><li>\u6b64\u7b56\u7565\u6bd4\u8f83\u9002\u5408\u670d\u52a1\u5668\u7684\u786c\u4ef6\u914d\u7f6e\u5dee\u522b\u6bd4\u8f83\u5927\u7684\u60c5\u51b5\u3002<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3\u3001ip_hash<\/h2>\n\n\n\n<p>\u6307\u5b9a\u8d1f\u8f7d\u5747\u8861\u5668\u6309\u7167\u57fa\u4e8e\u5ba2\u6237\u7aefIP\u7684\u5206\u914d\u65b9\u5f0f\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u786e\u4fdd\u4e86\u76f8\u540c\u7684\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u4e00\u76f4\u53d1\u9001\u5230\u76f8\u540c\u7684\u670d\u52a1\u5668\uff0c\u4ee5\u4fdd\u8bc1session\u4f1a\u8bdd\u3002\u8fd9\u6837\u6bcf\u4e2a\u8bbf\u5ba2\u90fd\u56fa\u5b9a\u8bbf\u95ee\u4e00\u4e2a\u540e\u7aef\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u89e3\u51b3session\u4e0d\u80fd\u8de8\u670d\u52a1\u5668\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">#\u52a8\u6001\u670d\u52a1\u5668\u7ec4\n    upstream dynamic_zuoyu {\n        ip_hash;    #\u4fdd\u8bc1\u6bcf\u4e2a\u8bbf\u5ba2\u56fa\u5b9a\u8bbf\u95ee\u4e00\u4e2a\u540e\u7aef\u670d\u52a1\u5668\n        server localhost:8080   weight=2;  #tomcat 7.0\n        server localhost:8081;  #tomcat 8.0\n        server localhost:8082;  #tomcat 8.5\n        server localhost:8083   max_fails=3 fail_timeout=20s;  #tomcat 9.0\n    }<\/pre><\/div>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5728nginx\u7248\u672c1.3.1\u4e4b\u524d\uff0c\u4e0d\u80fd\u5728ip_hash\u4e2d\u4f7f\u7528\u6743\u91cd\uff08weight\uff09\u3002<\/li><li>ip_hash\u4e0d\u80fd\u4e0ebackup\u540c\u65f6\u4f7f\u7528\u3002<\/li><li>\u6b64\u7b56\u7565\u9002\u5408\u6709\u72b6\u6001\u670d\u52a1\uff0c\u6bd4\u5982session\u3002<\/li><li>\u5f53\u6709\u670d\u52a1\u5668\u9700\u8981\u5254\u9664\uff0c\u5fc5\u987b\u624b\u52a8down\u6389\u3002<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">4\u3001least_conn<\/h2>\n\n\n\n<p>\u628a\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u8fde\u63a5\u6570\u8f83\u5c11\u7684\u540e\u7aef\u670d\u52a1\u5668\u3002\u8f6e\u8be2\u7b97\u6cd5\u662f\u628a\u8bf7\u6c42\u5e73\u5747\u7684\u8f6c\u53d1\u7ed9\u5404\u4e2a\u540e\u7aef\uff0c\u4f7f\u5b83\u4eec\u7684\u8d1f\u8f7d\u5927\u81f4\u76f8\u540c\uff1b\u4f46\u662f\uff0c\u6709\u4e9b\u8bf7\u6c42\u5360\u7528\u7684\u65f6\u95f4\u5f88\u957f\uff0c\u4f1a\u5bfc\u81f4\u5176\u6240\u5728\u7684\u540e\u7aef\u8d1f\u8f7d\u8f83\u9ad8\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cleast_conn\u8fd9\u79cd\u65b9\u5f0f\u5c31\u53ef\u4ee5\u8fbe\u5230\u66f4\u597d\u7684\u8d1f\u8f7d\u5747\u8861\u6548\u679c\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">#\u52a8\u6001\u670d\u52a1\u5668\u7ec4\n    upstream dynamic_zuoyu {\n        least_conn;    #\u628a\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u8fde\u63a5\u6570\u8f83\u5c11\u7684\u540e\u7aef\u670d\u52a1\u5668\n        server localhost:8080   weight=2;  #tomcat 7.0\n        server localhost:8081;  #tomcat 8.0\n        server localhost:8082 backup;  #tomcat 8.5\n        server localhost:8083   max_fails=3 fail_timeout=20s;  #tomcat 9.0\n    }<\/pre><\/div>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u6b64\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u9002\u5408\u8bf7\u6c42\u5904\u7406\u65f6\u95f4\u957f\u77ed\u4e0d\u4e00\u9020\u6210\u670d\u52a1\u5668\u8fc7\u8f7d\u7684\u60c5\u51b5\u3002<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5\u3001\u7b2c\u4e09\u65b9\u7b56\u7565<\/h2>\n\n\n\n<p>\u7b2c\u4e09\u65b9\u7684\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u7684\u5b9e\u73b0\u9700\u8981\u5b89\u88c5\u7b2c\u4e09\u65b9\u63d2\u4ef6\u3002<\/p>\n\n\n\n<p>\u2460fair<\/p>\n\n\n\n<p>\u6309\u7167\u670d\u52a1\u5668\u7aef\u7684\u54cd\u5e94\u65f6\u95f4\u6765\u5206\u914d\u8bf7\u6c42\uff0c\u54cd\u5e94\u65f6\u95f4\u77ed\u7684\u4f18\u5148\u5206\u914d\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">#\u52a8\u6001\u670d\u52a1\u5668\u7ec4\n    upstream dynamic_zuoyu {\n        server localhost:8080;  #tomcat 7.0\n        server localhost:8081;  #tomcat 8.0\n        server localhost:8082;  #tomcat 8.5\n        server localhost:8083;  #tomcat 9.0\n        fair;    #\u5b9e\u73b0\u54cd\u5e94\u65f6\u95f4\u77ed\u7684\u4f18\u5148\u5206\u914d\n    }<\/pre><\/div>\n\n\n\n<p>\u2461url_hash<\/p>\n\n\n\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\u8981\u914d\u5408\u7f13\u5b58\u547d\u4e2d\u6765\u4f7f\u7528\u3002\u540c\u4e00\u4e2a\u8d44\u6e90\u591a\u6b21\u8bf7\u6c42\uff0c\u53ef\u80fd\u4f1a\u5230\u8fbe\u4e0d\u540c\u7684\u670d\u52a1\u5668\u4e0a\uff0c\u5bfc\u81f4\u4e0d\u5fc5\u8981\u7684\u591a\u6b21\u4e0b\u8f7d\uff0c\u7f13\u5b58\u547d\u4e2d\u7387\u4e0d\u9ad8\uff0c\u4ee5\u53ca\u4e00\u4e9b\u8d44\u6e90\u65f6\u95f4\u7684\u6d6a\u8d39\u3002\u800c\u4f7f\u7528url_hash\uff0c\u53ef\u4ee5\u4f7f\u5f97\u540c\u4e00\u4e2aurl\uff08\u4e5f\u5c31\u662f\u540c\u4e00\u4e2a\u8d44\u6e90\u8bf7\u6c42\uff09\u4f1a\u5230\u8fbe\u540c\u4e00\u53f0\u670d\u52a1\u5668\uff0c\u4e00\u65e6\u7f13\u5b58\u4f4f\u4e86\u8d44\u6e90\uff0c\u518d\u6b64\u6536\u5230\u8bf7\u6c42\uff0c\u5c31\u53ef\u4ee5\u4ece\u7f13\u5b58\u4e2d\u8bfb\u53d6\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">#\u52a8\u6001\u670d\u52a1\u5668\u7ec4\n    upstream dynamic_zuoyu {\n        hash $request_uri;    #\u5b9e\u73b0\u6bcf\u4e2aurl\u5b9a\u5411\u5230\u540c\u4e00\u4e2a\u540e\u7aef\u670d\u52a1\u5668\n        server localhost:8080;  #tomcat 7.0\n        server localhost:8081;  #tomcat 8.0\n        server localhost:8082;  #tomcat 8.5\n        server localhost:8083;  #tomcat 9.0\n    }<\/pre><\/div>\n\n\n\n<p>\u539f\u6587\u94fe\u63a5\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.cnblogs.com\/1214804270hacker\/p\/9325150.html\" target=\"_blank\">https:\/\/www.cnblogs.com\/1214804270hacker\/p\/9325150.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u5173\u4e8eNginx\u7684\u8d1f\u8f7d\u5747\u8861 \u5728\u670d\u52a1\u5668\u96c6\u7fa4\u4e2d\uff0cNginx\u8d77\u5230\u4e00\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\u7684\u89d2\u8272\uff08\u5373\u53cd\u5411\u4ee3\u7406\uff09\uff0c\u4e3a\u4e86\u907f\u514d\u5355\u72ec\u4e00 &hellip; <a href=\"https:\/\/www.tysql.com\/index.php\/2021\/06\/22\/nginx%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Nginx\u8d1f\u8f7d\u5747\u8861<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":1,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/posts\/26\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}