{"id":1633,"date":"2017-03-24T02:01:20","date_gmt":"2017-03-23T18:01:20","guid":{"rendered":"http:\/\/www.youthtribe.com\/?p=1633"},"modified":"2018-12-17T15:07:32","modified_gmt":"2018-12-17T07:07:32","slug":"nginx%e5%a6%82%e4%bd%95%e5%81%9aphp%e7%bd%91%e7%ab%99%e7%9a%84%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1","status":"publish","type":"post","link":"http:\/\/www.youthtribe.com\/archives\/1633","title":{"rendered":"nginx\u5982\u4f55\u505aphp\u7f51\u7ad9\u7684\u8d1f\u8f7d\u5747\u8861"},"content":{"rendered":"
web\u7f51\u7ad9\u8d1f\u8f7d\u5747\u8861\u662f\u89e3\u51b3\u5927\u6d41\u91cf\u7f51\u7ad9\u7684\u529e\u6cd5\u3002\u6211\u5f00\u59cb\u6478\u7d22\u7740\u5982\u4f55\u5b9e\u73b0nginx\u4e0b\u7684php\u7ad9\u70b9\u7684\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n
\u6700\u4f4e\u8981\u6c423\u53f0\u4e3b\u673a\u3002\u5176\u4e2d\u4e00\u53f0\u505a\u524d\u7aef\uff0c\u4e24\u53f0\u505a\u540e\u7aef\u3002\u6240\u6709\u8bf7\u6c42\u90fd\u662f\u901a\u8fc7\u524d\u7aef\uff0c\u7136\u540e\u524d\u7aef\u6839\u636e\u540e\u7aef\u670d\u52a1\u5668\u7684\u8d1f\u8f7d\u60c5\u51b5\u8fdb\u884c\u8bf7\u6c42\u7684\u5206\u53d1\uff0c\u6700\u540e\u518d\u901a\u8fc7\u524d\u7aef\u8fd4\u56de\u6570\u636e\u7ed9\u8bbf\u95ee\u8005\u3002<\/p>\n
\u524d\u7aef\u8981\u505a\u7684\u5c31\u662f\u53cd\u5411\u4ee3\u7406\uff08\u5177\u4f53\u8fd9\u4e2a\u542b\u4e49\uff0c\u8bf4\u5b9e\u8bdd\uff0c\u6211\u4e00\u76f4\u6ca1\u7406\u89e3\u592a\u900f\u5f7b\u3002\u3002\uff09\u3002\u4e3b\u8981\u6709\u4e24\u6b65\uff1a\u4e00\u662f\u8bbe\u7f6e\u540e\u7aef\u7684\u6240\u6709\u670d\u52a1\u5668\u5730\u5740\u3002\u4e8c\u662f\u8bbe\u7f6e\u524d\u7aef\u6240\u622a\u65ad\u3001\u83b7\u53d6\u7684\u8bf7\u6c42\u8981\u8f6c\u5411\u7684\u540e\u7aef\u7ec4\uff0c\u5176\u5b9e\u4e5f\u5c31\u662f\u7b2c\u4e00\u6b65\u4e2d\u7684\u8bbe\u7f6e\u503c\u3002<\/p>\n
upstream backend {<\/p>\n
#ip_hash;#\u8bf7\u6c42\u5206\u53d1\u65b9\u5f0f
\nserver backend1.ss.com weight=5;<\/p>\nserver backend2.ss.com weight=2;<\/p>\n
server backend3.ss.com weight=1;<\/p>\n
}<\/p><\/blockquote>\n
\n\u5728server\u57df\u5757\u4e2d\uff0c\u6dfb\u52a0\u6211\u4eec\u8981\u622a\u65ad\u7684\u8bf7\u6c42\uff0c\u8fdb\u884c\u8f6c\u53d1\u7ed9backend\u7ec4\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u8bbe\u7f6e\u4e3a\u622a\u65ad\u6240\u6709\u8bf7\u8bf7\u6c42\u3002<\/li>\n<\/ul>\n location \/ {
\n#\u8bbe\u7f6e\u4e3b\u673a\u5934\u548c\u5ba2\u6237\u7aef\u771f\u5b9e\u5730\u5740\uff0c\u4ee5\u4fbf\u670d\u52a1\u5668\u83b7\u53d6\u5ba2\u6237\u7aef\u771f\u5b9eIP
\n#proxy_set_header Host $host;
\n#proxy_set_header X-Real-IP $remote_addr;
\n#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
\n#\u7981\u7528\u7f13\u5b58<\/p>\n# proxy_buffering off;<\/p>\n
#\u8bbe\u7f6e\u53cd\u5411\u4ee3\u7406\u7684\u5730\u5740
\nproxy_pass http:\/\/backend; #\u8fd9\u91cc\u662f\u91cd\u70b9\uff01
\n}<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"web\u7f51\u7ad9\u8d1f\u8f7d\u5747\u8861\u662f\u89e3\u51b3\u5927\u6d41\u91cf\u7f51\u7ad9\u7684\u529e\u6cd5\u3002\u6211\u5f00\u59cb\u6478\u7d22\u7740\u5982\u4f55\u5b9e\u73b0nginx\u4e0b\u7684php\u7ad9\u70b9\u7684\u8d1f\u8f7d\u5747\u8861\u3002 \u6700\u4f4e\u8981\u6c423\u53f0\u4e3b\u673a\u3002\u5176\u4e2d\u4e00\u53f0\u505a\u524d\u7aef\uff0c\u4e24\u53f0\u505a\u540e\u7aef\u3002\u6240\u6709\u8bf7\u6c42\u90fd\u662f\u901a\u8fc7\u524d\u7aef\uff0c\u7136\u540e\u524d\u7aef\u6839\u636e\u540e\u7aef\u670d\u52a1\u5668\u7684\u8d1f\u8f7d\u60c5\u51b5\u8fdb\u884c\u8bf7\u6c42\u7684\u5206\u53d1\uff0c\u6700\u540e\u518d\u901a\u8fc7\u524d\u7aef\u8fd4\u56de\u6570\u636e\u7ed9\u8bbf\u95ee\u8005\u3002 \u524d\u7aef\u8981\u505a\u7684\u5c31\u662f\u53cd\u5411\u4ee3\u7406\uff08\u5177\u4f53\u8fd9\u4e2a\u542b\u4e49\uff0c\u8bf4\u5b9e\u8bdd\uff0c\u6211\u4e00\u76f4\u6ca1\u7406\u89e3\u592a\u900f\u5f7b\u3002\u3002\uff09\u3002\u4e3b\u8981\u6709\u4e24\u6b65\uff1a\u4e00\u662f\u8bbe\u7f6e\u540e\u7aef\u7684\u6240\u6709\u670d\u52a1\u5668\u5730\u5740\u3002\u4e8c\u662f\u8bbe\u7f6e\u524d\u7aef\u6240\u622a\u65ad\u3001\u83b7\u53d6\u7684\u8bf7\u6c42\u8981\u8f6c\u5411\u7684\u540e\u7aef\u7ec4\uff0c\u5176\u5b9e\u4e5f\u5c31\u662f\u7b2c\u4e00\u6b65\u4e2d\u7684\u8bbe\u7f6e\u503c\u3002 \u5728nginx.conf\u4e2d\u8bbe\u7f6e\u6240\u6709\u540e\u7aef\u670d\u52a1\u5668\uff0c\u540c\u65f6\u8d77\u4e00\u4e2a\u540d\u5b57\u3002\u901a\u5e38\u8bbe\u7f6e\u4e3abackend\u3002pustream\u5e94\u8be5\u653e\u5728http\u57df\u5757\u4e2d\u3002 upstream backend<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,273,224],"tags":[],"_links":{"self":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1633"}],"collection":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/comments?post=1633"}],"version-history":[{"count":4,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1633\/revisions"}],"predecessor-version":[{"id":1771,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1633\/revisions\/1771"}],"wp:attachment":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/media?parent=1633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/categories?post=1633"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/tags?post=1633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}