{"id":137654,"date":"2020-07-15T12:12:59","date_gmt":"2020-07-15T04:12:59","guid":{"rendered":"http:\/\/4563.org\/?p=137654"},"modified":"2020-07-15T12:12:59","modified_gmt":"2020-07-15T04:12:59","slug":"%e5%bf%ab%e9%80%9f%e5%88%87%e6%8d%a2-nginx-%e7%9a%84-upstream-%e6%9c%89%e6%ad%a3%e7%a1%ae%e7%9a%84%e5%a7%bf%e5%8a%bf%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=137654","title":{"rendered":"\u5feb\u901f\u5207\u6362 Nginx \u7684 upstream \u6709\u6b63\u786e\u7684\u59ff\u52bf\u5417\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5feb\u901f\u5207\u6362 Nginx \u7684 upstream \u6709\u6b63\u786e\u7684\u59ff\u52bf\u5417\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : saytesnake <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>upstream foo {  server 127.0.0.1:8081; }  upstream foo_back {  server 127.0.0.1:8080; }  upstream bar {  server 127.0.0.2:8081; }  upstream bar_back {  server 127.0.0.2:8080; }  localtion \/ {  proxy_pass http:\/\/foo; }  localtion \/back {  proxy_pass http:\/\/foo_back; } <\/code><\/pre>\n<p>\u8981\u5207\u6362\u5230 bar \u5c31\u8981\u4fee\u6539 proxy_pass \u91cc\u9762\u7684\uff0c\u5982\u679c\u5b9e\u9645\u60c5\u51b5\u662f\u5f88\u591a upstream\uff0c\u5f88\u591a localtion\uff0c\u6709\u4ec0\u4e48\u63d2\u4ef6\u6216\u662f lua \u4e4b\u7c7b\u7684\u53ef\u4ee5\u5b9e\u73b0\u5feb\u6377\u5207\u6362\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2589890\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jirajine <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u53ef\u80fd\u9700\u8981 treafik <br \/>https:\/\/containo.us\/traefik\/                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2589891\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : halfcrazy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             lua \u53d8\u91cf\u66ff\u4ee3 proxy_pass \u91cc\u5199\u6b7b\u7684 upstream<br \/>set $backend &#8220;default&#8221;;<br \/>rewrite_by_lua_block {<br \/> ngx.var.backend=&#8221;foo&#8221;<br \/>}<br \/>proxy_pass http:\/\/backend;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2589892\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : des <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u4e00\u4e0b\u8fd9\u4e2a\uff1f<br \/>http:\/\/nginx.org\/en\/docs\/http\/ngx_http_upstream_conf_module.html<br \/>http:\/\/nginx.org\/en\/docs\/http\/ngx_http_api_module.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2589893\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : monkeyNik <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u53c2\u8003\uff1aGithub \u7684 yzprofile\/ngx_http_dyups_module\uff0c\u53ef\u4ee5\u52a8\u6001\u589e\u52a0\u3001\u5220\u9664\u3001\u66f4\u65b0 upstream<br \/>\u6216\u8005\u4e5f\u53ef\u4ee5\u8003\u8651\u662f\u7528 nginx.zone \u8fd9\u4e2a\u7f51\u7ad9\u4e0a\u9762\u7684 Nginx \u53d1\u884c\u7248\uff0c\u63d0\u4f9b\u4e86\u4e0d\u4ec5\u4ec5\u662f\u52a8\u6001 upstream \u66f4\u65b0\uff0c\u4e5f\u63d0\u4f9b\u4e86\u52a8\u6001 location \u66f4\u65b0\uff0c\u65e0\u9700 reload \u3002\u4e5f\u63d0\u4f9b\u4e86\u5404\u79cd\u5176\u4ed6\u529f\u80fd\uff0c\u57fa\u672c\u5168\u90e8\u6307\u4ee4\u5bf9\u52a8\u6001 location \u652f\u6301\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5feb\u901f\u5207\u6362 Nginx \u7684 upst&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/137654"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=137654"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/137654\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=137654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=137654"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=137654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}