\r\nunzip nginx-upsync-module-master.zip \r\ntar -zxvf nginx-1.21.0.tar.gz\r\n<\/pre>\n3.\u5b89\u88c5\u76f8\u5173\u6269\u5c55<\/p>\n
\r\napt-get install -y gcc autoconf automake make libpcre3 libpcre3-dev openssl libssl-dev zlib1g-dev\r\n<\/pre>\n4.\u8fdb\u5165\u89e3\u538b\u7684nginx\u5b89\u88c5\u5305\uff0c\u8fdb\u884c\u7f16\u8bd1\u5b89\u88c5<\/p>\n
\r\ncd \/home\/nginx-1.21.0\r\n\r\n\r\n#\u901a\u8fc7\u547d\u4ee4\u67e5\u770bnginx\u7248\u672c\u4e0e\u7f16\u8bd1\u4fe1\u606f\r\nnginx -V\r\n\r\n#\u590d\u5236\u76f8\u5173\u7f16\u8bd1\u4fe1\u606f\uff0c\u6dfb\u52a0nginx- upsync-module-master\u6a21\u5757\r\n.\/configure --prefix=\/etc\/nginx --sbin-path=\/usr\/sbin\/nginx --modules-path=\/usr\/lib\/nginx\/modules --conf-path=\/etc\/nginx\/nginx.conf --error-log-path=\/var\/log\/nginx\/error.log --http-log-path=\/var\/log\/nginx\/access.log --pid-path=\/var\/run\/nginx.pid --lock-path=\/var\/run\/nginx.lock --http-client-body-temp-path=\/var\/cache\/nginx\/client_temp --http-proxy-temp-path=\/var\/cache\/nginx\/proxy_temp --http-fastcgi-temp-path=\/var\/cache\/nginx\/fastcgi_temp --http-uwsgi-temp-path=\/var\/cache\/nginx\/uwsgi_temp --http-scgi-temp-path=\/var\/cache\/nginx\/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=\/data\/builder\/debuild\/nginx-1.21.0\/debian\/debuild-base\/nginx-1.21.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --add-module=\/home\/nginx-upsync-module-master\r\n<\/pre>\n5.\u7f16\u8bd1\u5b89\u88c5<\/p>\n
\r\nmake && make install\r\n<\/pre>\n3 nginx\u52a8\u6001\u8d1f\u8f7d\u5747\u8861\u914d\u7f6e<\/strong><\/div>\n\r\nupstream edu{\r\n server 192.168.35.138;\r\n upsync 172.17.0.3:8500\/v1\/kv\/upstreams\/nginx_test upsync_timeout=6m upsync_interval=500ms upsync_type=consul strong_dependency=off;\r\n upsync_dump_path \/etc\/nginx\/conf.d\/server_test.conf;\r\n include \/etc\/nginx\/conf.d\/server_test.conf;\r\n}\r\nserver {\r\n listen 80;\r\n listen [::]:80;\r\n server_name localhost;\r\n root \/docker\/www\/;\r\n index index.php index.html;\r\n\r\n location \/ {\r\n proxy_pass http:\/\/edu;\r\n }\r\n}\r\n<\/pre>\n\u5f80consul\u52a0\u5165nginx\u670d\u52a1<\/p>\n
\r\ncurl -X PUT -d '{\"weight\":1,\"max_fails\":2,\"fail_timeout\":10}' http:\/\/192.168.35.139:8500\/v1\/kv\/upstreams\/nginx_test\/192.168.35.131:81\r\n\r\ncurl -X PUT -d '{\"weight\":1,\"max_fails\":2,\"fail_timeout\":10}' http:\/\/192.168.35.139:8500\/v1\/kv\/upstreams\/nginx_test\/192.168.35.131:80\r\n<\/pre>\n\u63a5\u7740\u67e5\u770bserver_test.conf\u6587\u4ef6,\u770b\u770bconsul\u662f\u5426\u6709\u5c06\u6211\u4eec\u65b0\u589e\u7684nginx\u670d\u52a1\u52a0\u5165\u5230\u8d1f\u8f7d\u5747\u8861\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Consul \u662f\u4e00\u4e2a\u652f\u6301\u591a\u6570\u636e\u4e2d\u5fc3\u5206\u5e03\u5f0f\u9ad8\u53ef\u7528\u7684\u670d\u52a1\u53d1\u73b0\u548c\u914d\u7f6e\u5171\u4eab\u7684\u670d\u52a1\u8f6f\u4ef6\u3002 \u670d\u52a1\u53d1\u73b0\u4ee5\u53ca\u6ce8\u518c\uff1a\u5f53\u670d\u52a1Pro […]<\/p>\n","protected":false},"author":1903,"featured_media":225362,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-225352","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/225352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=225352"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/225352\/revisions"}],"predecessor-version":[{"id":225397,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/225352\/revisions\/225397"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/225362"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=225352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=225352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=225352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}