在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:yzprofile/ngx_http_dyups_module开源软件地址:https://github.com/yzprofile/ngx_http_dyups_module开源编程语言:C 78.6%开源软件介绍:DescriptionThis module can be used to update your upstream-list without reloadding Nginx. Table of Contents
Examplefile: conf/nginx.conf
If your original config looks like this:
please replace it with:
file: conf/upstream.conf
Installation
$ git clone git://github.com/yzprofile/ngx_http_dyups_module.git
# to compile as a static module
$ ./configure --add-module=./ngx_http_dyups_module
# to compile as a dynamic module
$ ./configure --add-dynamic-module=./ngx_http_dyups_module
$ git clone git://github.com/yzprofile/ngx_http_dyups_module.git
$ git clone [email protected]:yzprofile/nginx_upstream_check_module.git
$ git clone [email protected]:openresty/lua-nginx-module.git
# to compile as a static module
$ ./configure --add-module=./nginx_upstream_check_module --add-module=./lua-nginx-module --add-module=./ngx_http_dyups_module Directivesdyups_interfaceSyntax: dyups_interface Default: Context: This directive set the interface location where you can add or delete the upstream list. See the section of Interface for detail. dyups_shm_zone_sizeSyntax: dyups_shm_zone_size Default: Context: This directive set the size of share memory which used to store the commands. restful interfaceGET
POST
DELETE
Call the interface, when you get the return code is If you got The /list and /detail interface will return Other code means you should modify your commands and call the interface again.
Sample» curl -H "host: dyhost" 127.0.0.1:8080
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.3.13</center>
</body>
</html>
» curl -d "server 127.0.0.1:8089;server 127.0.0.1:8088;" 127.0.0.1:8081/upstream/dyhost
success
» curl -H "host: dyhost" 127.0.0.1:8080
8089
» curl -H "host: dyhost" 127.0.0.1:8080
8088
» curl 127.0.0.1:8081/detail
host1
server 127.0.0.1:8088 weight=1 max_conns=0 max_fails=1 fail_timeout=10 backup=0 down=0
host2
server 127.0.0.1:8089 weight=1 max_conns=0 max_fails=1 fail_timeout=10 backup=0 down=0
dyhost
server 127.0.0.1:8089 weight=1 max_conns=0 max_fails=1 fail_timeout=10 backup=0 down=0
server 127.0.0.1:8088 weight=1 max_conns=0 max_fails=1 fail_timeout=10 backup=0 down=0
» curl -i -X DELETE 127.0.0.1:8081/upstream/dyhost
success
» curl 127.0.0.1:8081/detail
host1
server 127.0.0.1:8088 weight=1 max_conns=0 max_fails=1 fail_timeout=10 backup=0 down=0
host2
server 127.0.0.1:8089 weight=1 max_conns=0 max_fails=1 fail_timeout=10 backup=0 down=0 C APIextern ngx_flag_t ngx_http_dyups_api_enable;
ngx_int_t ngx_dyups_update_upstream(ngx_str_t *name, ngx_buf_t *buf,
ngx_str_t *rv);
ngx_int_t ngx_dyups_delete_upstream(ngx_str_t *name, ngx_str_t *rv);
extern ngx_dyups_add_upstream_filter_pt ngx_dyups_add_upstream_top_filter;
extern ngx_dyups_del_upstream_filter_pt ngx_dyups_del_upstream_top_filter;
Lua API ExampleNOTICE:
you should add the directive content_by_lua '
local dyups = require "ngx.dyups"
local status, rv = dyups.update("test", [[server 127.0.0.1:8088;]]);
ngx.print(status, rv)
if status ~= ngx.HTTP_OK then
ngx.print(status, rv)
return
end
ngx.print("update success")
status, rv = dyups.delete("test")
if status ~= ngx.HTTP_OK then
ngx.print(status, rv)
return
end
ngx.print("delete success")
';
Change LogRELEASE V0.2.9Feature: Added add/del upstream filter to make other modules operate upstream easily after upstream changed RELEASE V0.2.8Bugfixed: upstream connect failed caused coredump RELEASE V0.2.7Supported: C API and Lua API RELEASE V0.2.6Bugfixed: Supported sandbox before updatting RELEASE V0.2.5
RELEASE V0.2.4
RELEASE V0.2.2
RELEASE V0.2.0
CompatibilityTengine CompatibilityThis module has been merged into Tengine. Module Compatibility
Run Tests$ hg clone http://hg.nginx.org/nginx-tests/ ..
(Or git clone [email protected]:nginx/nginx-tests/ .. if you prefer the GitHub mirror)
$ TEST_NGINX_BINARY=/path/to/your/nginx/dir/sbin/nginx prove -I ../nginx-tests/lib ./t/dyups.t To make the tests pass, you should also install lua-nginx-module and patched upstream check module. Authoryzprofile (袁茁) [email protected] chobits (王笑臣) [email protected], Alibaba Inc. Copyright & LicenseThese codes are licenced under the BSD license.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论