Nginx ELB/ALB dynamic upstreams

Source: Internet
Author: User

Nginx ELB/ALB dynamic upstreams
Nginx-dynamic-upstreams (https://github.com/johnyin123/nginx-dynamic-upstreams)
Description

Nginx dynamic upstream (http & stream) use http json

Add (server, backup, down, weight, max_conns, max_fails, fail_timeout)
server : must setbackup noset : falsedown noset : falseweight>0 else : 1max_conns>0 else : 0max_fails>0 else : 1fail_timeout>0 else : 10 
Del (name, server, backup, down)
name/server must set at least onebackup noset : falsedown noset : false 
Edit (name, server, backup)
name/server must set at least onebackup noset : falseothers can modify, noset no modify 
Example: List:
{"method": "lst"} 
Add:
{"method": "add","params": [{ "http":{ "upsname" : "upsname", "peers":[{ "server":"10.0.2.11:9900", "weight":10, "max_conns":0, "max_fails":3, "fail_timeout":60, "backup": true , "down": false },{}]}},{ "stream":{ "upsname" : "stream_ups", "peers":[{ "server":"10.0.2.11:9900", "weight":-10, "max_conns":0, "max_fails":3, "fail_timeout":60, "backup": true , "down": false },{}]}}]} 
Del:
{"method": "del","params": [{ "http":{ "upsname" : "upsname", "peers":[{ "name":"[::1]:10001", "server":"localhost:10001", "backup": false, "down": false },{}]}},{ "stream":{ "upsname" : "stream_ups", "peers": [{ "name":"[::1]:10001", "server":"localhost:10001", "backup": false, "down": false },{}]}}]} 
Modify:
{"method": "edit","params": [{ "http":{ "upsname" : "upsname", "peers":[{ "name":"127.0.0.1:10001", "server":"localhost:10001", "backup": true, "weight":10, "max_conns":0, "max_fails":3, "fail_timeout":60, "down": false },{}]}},{ "stream":{ "upsname" : "stream_ups", "peers":[{ "name":"127.0.0.1:10001", "server":"localhost:10001", "backup": true, "weight":-10, "max_conns":0, "max_fails":3, "fail_timeout":60, "down": false },{}]}}]} 
Return Result (list)
{"code": 0,"message": [{"upsname": "http_upsname","number": 2,"total_weight": 2,"type": "http","peers": [{"name": "127.0.0.1:10001","server": "localhost:10001","current_weight": 0,"effective_weight": 1,"weight": 1,"conns": 0,"max_conns": 0,"fails": 0,"max_fails": 1,"fail_timeout": 10,"slow_start": 0,"start_time": 0,"down": false,"backup": false},{"name": "[::1]:10001","server": "localhost:10001","current_weight": 0,"effective_weight": 1,"weight": 1,"conns": 0,"max_conns": 0,"fails": 0,"max_fails": 1,"fail_timeout": 10,"slow_start": 0,"start_time": 0,"down": false,"backup": false}]},{"upsname": "stream_upsname","number": 1,"total_weight": 1,"type": "stream","peers": [{"name": "127.0.0.1:10002","server": "127.0.0.1:10002","current_weight": 0,"effective_weight": 1,"weight": 1,"conns": 0,"max_conns": 0,"fails": 0,"max_fails": 1,"fail_timeout": 10,"slow_start": 0,"start_time": 0,"down": false,"backup": false}]}]} 
Return Result (add/modify/del) success (code = 0)
{"code": 0,"message": {"success": 0,"failed": 4}} 
Failed (code! = 0)
{"code": -1009,"message": "No upstream found"} 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.