跳到主要内容

HTTP协议代理

参考案例:

[[proxies]]
name = "web"
protocol = "http"
custom_domains = ["a.domain.com", "b.domain.com"]
targets = [
{ host = "127.0.0.1", port = 8001, weight = 1, name = "web-instance-1" }
]

如果配置了基础域名(base_domain)可以自定义子域名:

[[proxies]]
name = "web"
protocol = "http"
sub_domains = ["a", "b"]
targets = [
{ host = "127.0.0.1", port = 8001, weight = 1, name = "web-instance-1" }
]

或采用自动分配域名,系统会随机生成一个子域名

[[proxies]]
name = "web"
protocol = "http"
auto_domain = true
targets = [
{ host = "127.0.0.1", port = 8001, weight = 1, name = "web-instance-1" }
]

远程访问地址:

提示

http_proxy_port 是服务端配置的 HTTP 代理端口,默认为 80,访问时需要替换为实际配置的端口号。查看服务端配置文档, 更多细节请参考域名配置

参数说明

参数名类型默认值描述必填
nameString-代理名称,唯一标识一个代理配置
protocolString-协议类型
custom_domainsArray<String>-自定义域名列表,配置完整域名
sub_domainsArray<String>-子域名列表,配合服务端 base_domain 使用
auto_domainBooleantrue是否自动分配子域名
targetsArray<Object>-目标服务列表,内网真实服务列表,支持单机和集群
enabledBooleantrue是否开启代理

targets 子参数说明

参数名类型默认值描述必填
hostString127.0.0.1目标服务主机地址
portInteger-目标服务端口
weightInteger1负载均衡权重,用于权重负载均衡算法
nameString-目标服务名称