title | tags | grammar_cjkRuby |
---|---|---|
动态upstream |
dynamic upstream,OpenResty,nginx lua |
true |
简易的动态upstream~ 暂时算法仅仅有ip_hash,url_hash,random weight.polling [权重+轮询] polling [beta]
安装 bash目录下的 install.sh 脚本 具体该脚本其他用法直接看源码吧~
sudo sh ./install.sh dynamic_upstream
使用 动态域名相关配置,直接看样例吧,比较好理解。 bal_list 源站服务器列表 [ip,port,[weight]] mode 负载均衡算法 certs 配置证书的 key dynamic_host.json DEMO
{
"www.abc.com": {
"bal_list": [["127.0.0.1",81],["127.0.0.1",82],["127.0.0.1",83]],
"mode": "ip_hash"
},
"www.test.com": {
"bal_list": [["127.0.0.1",81],["127.0.0.1",82]],
"mode": "url_hash",
"certs":"blah.com"
},
"www.test2.com": {
"bal_list": [["127.0.0.1",84],["127.0.0.1",83],["127.0.0.1",82],["127.0.0.1",81]],
"mode": "random",
"certs":"example.foo.com"
},
"www.abc1.com": {
"bal_list": [["127.0.0.1",81],["127.0.0.1",82],["127.0.0.1",83]],
"mode": "polling"
},
"www.abc2.com": {
"bal_list": [["127.0.0.1",81,1],["127.0.0.1",82],["127.0.0.1",83,9]],
"mode": "weight.polling"
}
}
证书相关配置,key为域名,ssl_certificate 证书(base64后),ssl_certificate_key 私钥(base64后) dynamic_certs.json
{
"blah.com":{
"e_time":"2020-09-09 19:30:00",
"ssl_certificate":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURKakNDQWc2Z0F3SUJBZ0lVUTVVWVF0UTllZjlWRkVnL1VkL0RkaDNzSk9jd0RRWUpLb1pJaHZjTkFRRUwKQlFBd0R6RU5NQXNHQTFVRUF4TUVjM1JoY2pBZUZ3MHhOakExTVRFd01ESXhORE5hRncweE5qQTJNVEF3TURJeQpNVE5hTUJNeEVUQVBCZ05WQkFNVENHSnNZV2d1WTI5dE1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBCk1JSUJDZ0tDQVFFQW05M1BWTVBMOWlZVWQwWH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工作。
- Copyright and License GPL(GNU General Public License) Copyright (C) 2011-2016, by zj