跳到主要内容

负载均衡

为代理配置多个后端目标时,按策略分发流量。适用于 HTTP / HTTPS / TCP / UDP 协议

# orbien.toml
[[proxies]]
name = "web"
protocol = "http"
custom_domains = ["web.domain.com"]
load_balance_strategy = "roundrobin"
targets = [
{ host = "127.0.0.1", port = 8001, weight = 1, name = "backend-1" },
{ host = "127.0.0.1", port = 8002, weight = 2, name = "backend-2" }
]

参数说明​

参数名类型默认值描述必填
load_balance_strategyStringroundrobin负载均衡策略否
targetsArray内网服务列表是

负载均衡算法​

值描述
roundrobin轮询
weight加权轮询
random随机
leastconn最少连接

真实内网服务​

参数名类型默认值描述必填
hostString127.0.0.1后端地址否
portInteger后端端口是
weightInteger1权重否
nameString目标名称否
说明

也可使用 local_ip / local_port 配置单个目标;与 targets 可同时存在。