{"id":473,"date":"2021-03-12T21:57:31","date_gmt":"2021-03-12T13:57:31","guid":{"rendered":"https:\/\/blog.73007300.xyz\/?p=473"},"modified":"2021-03-12T21:57:31","modified_gmt":"2021-03-12T13:57:31","slug":"nginx%e5%af%b9%e6%8c%87%e5%ae%9a%e7%ab%af%e5%8f%a3%e7%9a%84tcp%e5%92%8cudp%e5%8d%8f%e8%ae%ae%e8%bf%9b%e8%a1%8c%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1","status":"publish","type":"post","link":"https:\/\/blog.73007300.xyz\/?p=473","title":{"rendered":"nginx\u5bf9\u6307\u5b9a\u7aef\u53e3\u7684TCP\u548cUDP\u534f\u8bae\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861"},"content":{"rendered":"\n<p>nginx\u65e2\u53ef\u4ee5\u5bf9tcp\u534f\u8bae\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\uff0c\u4e5f\u53ef\u4ee5\u5bf9UDP\u534f\u8bae\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002<br>\u4ee5shadowsock\u4e3a\u4f8b\uff0c\u5047\u5982\u6211\u73b0\u5728\u67093\u53f0shadowsocks:<\/p>\n\n\n\n<p>11.11.11.11:2222<br>33.33.33.33:4444<br>55.55.55.55:6666<\/p>\n\n\n\n<p>\u6bcf\u53f0\u4e0a\u90fd\u540c\u65f6\u5f00\u4e86TCP\u548cUDP\u534f\u8bae\u3002\u800c\u4e14\u6bcf\u53f0\u4e0a\u7684\u52a0\u5bc6\u65b9\u5f0f\u548c\u5bc6\u7801\u90fd\u4e00\u6837\u3002<br>\u8fd9\u70b9\u5f88\u91cd\u8981\uff0c\u6bcf\u53f0\u4e0a\u7684\u52a0\u5bc6\u65b9\u5f0f\u548c\u5bc6\u7801\u5fc5\u987b\u4e00\u6837\u3002<br>\u73b0\u5728\u6211\u8981\u901a\u8fc7\u672c\u5730nginx\u5b9e\u65bd\u8d1f\u8f7d\u5747\u8861\u3002<br>\u4ee5\u6700\u7b80\u5355\u7684\u8f6e\u8be2\u5f0f\uff08Round Robin\uff09\u8d1f\u8f7d\u4e3a\u4f8b\u3002<br>\u4ee5Debian\u4e3a\u4f8b\uff0c\u5148\u5b89\u88c5nginx\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install nginx-full -y<\/code><\/pre>\n\n\n\n<p>\u4fee\u6539\u5982\u4e0bip\u548c\u7aef\u53e3\uff0c\u8ffd\u52a0\u5230\/etc\/nginx\/nginx.conf \u6587\u4ef6\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># https:\/\/docs.nginx.com\/nginx\/admin-guide\/load-balancer\/tcp-udp-load-balancer\/\n# \u653e\u7f6e\u5728\/etc\/nginx\/nginx.conf\u7684 http{} \u90e8\u5206\u7684\u4e0b\u9762\nstream {\n    upstream shadowsocks_tcp {\n        # By default, NGINX uses the Round Robin algorithm to load balance traffic\n        server 11.11.11.11:2222 max_fails=2 fail_timeout=5;\n        server 33.33.33.33:4444 max_fails=2 fail_timeout=5;\n        server 55.55.55.55:6666 max_fails=2 fail_timeout=5;\n    }\n    \n    upstream shadowsocks_udp {\n        # By default, NGINX uses the Round Robin algorithm to load balance traffic\n        server 11.11.11.11:2222 max_fails=2 fail_timeout=5;\n        server 33.33.33.33:4444 max_fails=2 fail_timeout=5;\n        server 55.55.55.55:6666 max_fails=2 fail_timeout=5;\n    }\n    \n    server {\n\t\t# https:\/\/docs.nginx.com\/nginx\/admin-guide\/load-balancer\/tcp-health-check\/\n        listen        8388;\n        proxy_pass    shadowsocks_tcp;\n        proxy_timeout 3s;\n        proxy_connect_timeout 1s;\n    }\n    \n    server {\n\t\t# https:\/\/docs.nginx.com\/nginx\/admin-guide\/load-balancer\/udp-health-check\/\n        listen     8388 udp;\n        proxy_pass shadowsocks_udp;\n\t\tproxy_timeout   1s;\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u91cd\u542fnginx\u4f7f\u914d\u7f6e\u751f\u6548\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start nginx.service<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u5c31\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6ess\u8fde\u63a5\u5230nginx\u76848388\u7aef\u53e3 \uff0c\u5747\u5300\u7684\u8bbf\u95ee\u5230\u6bcf\u4e2a\u8282\u70b9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nginx\u65e2\u53ef\u4ee5\u5bf9tcp\u534f\u8bae\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\uff0c\u4e5f\u53ef\u4ee5\u5bf9UDP\u534f\u8bae\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002\u4ee5shadowsock\u4e3a\u4f8b\uff0c\u5047\u5982\u6211\u73b0\u5728\u67093\u53f0shadowsocks: 11.11.11.11:222233.33.33.33:444455.55.55.55:6666 \u6bcf\u53f0\u4e0a\u90fd\u540c\u65f6\u5f00\u4e86TCP\u548cUDP\u534f\u8bae\u3002\u800c\u4e14\u6bcf\u53f0\u4e0a\u7684\u52a0\u5bc6\u65b9\u5f0f\u548c\u5bc6\u7801\u90fd\u4e00\u6837\u3002\u8fd9\u70b9\u5f88\u91cd\u8981\uff0c\u6bcf\u53f0\u4e0a\u7684\u52a0\u5bc6\u65b9\u5f0f\u548c\u5bc6\u7801\u5fc5\u987b\u4e00\u6837\u3002\u73b0\u5728\u6211\u8981\u901a\u8fc7\u672c\u5730nginx\u5b9e\u65bd\u8d1f\u8f7d\u5747\u8861\u3002\u4ee5\u6700\u7b80\u5355\u7684\u8f6e\u8be2\u5f0f\uff08Round Robin\uff09\u8d1f\u8f7d\u4e3a\u4f8b\u3002\u4ee5Debian\u4e3a\u4f8b\uff0c\u5148\u5b89\u88c5nginx\uff1a \u4fee\u6539\u5982\u4e0bip\u548c\u7aef\u53e3\uff0c\u8ffd\u52a0\u5230\/etc\/nginx\/nginx.conf \u6587\u4ef6\u4e2d\uff1a \u91cd\u542fnginx\u4f7f\u914d\u7f6e\u751f\u6548\uff1a \u7136\u540e\u5c31\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6ess\u8fde\u63a5\u5230nginx\u76848388\u7aef\u53e3 \uff0c\u5747\u5300\u7684\u8bbf\u95ee\u5230\u6bcf\u4e2a\u8282\u70b9\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,2],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/473"}],"collection":[{"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=473"}],"version-history":[{"count":1,"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":474,"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/473\/revisions\/474"}],"wp:attachment":[{"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.73007300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}