微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

程序名称:nginx-upsync-module

授权协议: BSD

操作系统: 跨平台

开发语言: C/C++

nginx-upsync-module 介绍

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 http://test;
        }

        location = /bar {
            proxy_pass http://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 http://test;
        }

        location = /bar {
            proxy_pass http://bar;
        }

        location = /upstream_show {
            upstream_show;
        }

    }
}

nginx-upsync-module 官网

https://github.com/weibocom/nginx-upsync-module

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐