nginx-upsync-module 基于 Nginx 实现动态配置的模块开源项目

我要开发同款
匿名用户2017年12月05日
44阅读
开发技术C/C++
所属分类Nginx扩展模块、服务器软件
授权协议BSD

作品详情

nginx-upsync-module是微博开源的一个基于Nginx实现动态配置的模块,通过拉取Consul或 etcd(及其它)的上游数据,实现无需重新加载Nginx,动态修改后端服务器属性(weight,max_fails,down...)。

修改配置文件并重新启动Nginx可能并不总是很方便。例如,当遇到大流量和高负载,重启Nginx并在此时重新加载配置会进一步增加系统负载,并可能暂时降低性能。使用nginx-upsync-module模块则可以在不影响性能的情况下,更加平滑的扩展和收缩。

nginx-consul:

http {    upstream test {        upsync 127.0.0.1:8500/v1/kv/upstreams/test/ upsync_timeout=6m upsync_interval=500ms upsync_type=consul strong_dependency=off;        upsync_dump_path /usr/local/nginx/conf/servers/servers_test.conf;        include /usr/local/nginx/conf/servers/servers_test.conf;    }    upstream bar {        server 127.0.0.1:8090 weight=1 fail_timeout=10 max_fails=3;    }    server {        listen 8080;        location = /proxy_test {            proxy_pass https://test;        }        location = /bar {            proxy_pass https://bar;        }        location = /upstream_show {            upstream_show;        }    }}

nginx-etcd:

http {    upstream test {        upsync 127.0.0.1:2379/v2/keys/upstreams/test upsync_timeout=6m upsync_interval=500ms upsync_type=etcd strong_dependency=off;        upsync_dump_path /usr/local/nginx/conf/servers/servers_test.conf;        include /usr/local/nginx/conf/servers/servers_test.conf;    }    upstream bar {        server 127.0.0.1:8090 weight=1 fail_timeout=10 max_fails=3;    }    server {        listen 8080;        location = /proxy_test {            proxy_pass https://test;        }        location = /bar {            proxy_pass https://bar;        }        location = /upstream_show {            upstream_show;        }    }}
查看全文
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论