Nginx C 模块 lua-upstream-nginx-module
Synopsis
http { upstream foo.com { server 127.0.0.1 fail_timeout=53 weight=4 max_fails=100; server agentzh.org:81; } upstream bar { server 127.0.0.2; } server { listen 8080; # sample output for the following /upstream interface: # upstream foo.com: # addr = 127.0.0.1:80, weight = 4, fail_timeout = 53, max_fails = 100 # addr = 106.187.41.147:81, weight = 1, fail_timeout = 10, max_fails = 1 # upstream bar: # addr = 127.0.0.2:80, weight = 1, fail_timeout = 10, max_fails = 1 location = /upstreams { default_type text/plain; content_by_lua ' local concat = table.concat local upstream = require "ngx.upstream" local get_servers = upstream.get_servers local get_upstreams = upstream.get_upstreams local us = get_upstreams() for _, u in ipairs(us) do ngx.say("upstream ", u, ":") local srvs, err = get_servers(u) if not srvs then ngx.say("failed to get servers in upstream ", u) else for _, srv in ipairs(srvs) do local first = true for k, v in pairs(srv) do if first then first = false ngx.print(" ") else ngx.print(", ") end if type(v) == "table" then ngx.print(k, " = {", concat(v, ", "), "}") else ngx.print(k, " = ", v) end end ngx.print("\\n") end end end '; } } }
官方网站:http://www.open-open.com/lib/view/home/1453425789761
本文由用户 GitCamp 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!