j9九游会登录/ 应用平台 appstage/ / / / / 转发策略配置
更新时间:2026-01-04 gmt 08:00

转发策略配置-j9九游会登录

本章介绍通过iac进行转发策略配置的管理,包括监听下的转发策略、健康检查、后端服务器及动态路由管理。对应的资源类型为wisecloud::loadbalancer::slb::routerule。

表1 转发策略配置字段说明

参数名

类型

是否必选

说明

listenergroupname

string

slb监听名称,一个转发策略实例只能绑定一个监听实例。

targetgroups

list<targetgroupconfigbean>

后端集群。

routes

list<routerule>

转发策略(locations)。

dynamicroutes

list<dynamicrouterulebean>

动态路由。

表2 targetgroupconfigbean

参数名

类型

是否必选

说明

name

string

后端集群名,不超过150位,不包含特殊字符。

protocol

string

协议,取值为:http或https。

loadbalancer

targetgrouploadbalancerbean

后端集群负载均衡类型。

healthcheck

targetgrouphealthcheckbean

健康检查。

表3 targetgrouploadbalancerbean

参数名

类型

是否必选

说明

strategy

string

负载均衡算法,支持"roundrobin"、"protocolparam"、"ip_hash"、"least_conn"。

slowstartdelay

int

预热时延,不超过30。

slowstartperiod

int

预热周期,不超过30。

slowstartfactor

int

预热因子,默认为10,不小于1,不超过100。

hashparam

string

哈希转发字段名,strategy类型为protocolparam时必填

长度不超过50,由字母加数字,下划线,横杠,点组成。

customparam

string

自定义参数,不包含by_lua。

默认取第一个后端集群的健康检查配置,如果为空,使用默认值。

表4 targetgrouphealthcheckbean

参数名

类型

是否必选

说明

switchstatus

string

是否开启健康检查,取值为on或off,不填或者其他字符均为off。

protocol

string

协议,默认http,不可修改。

path

string

检查路径,长度不超过500,由字母、数字、横杠、下划线和点组成。

successcodes

string

成功码列表,100-600之间的数字,以逗号隔开。

healthythreshold

int

健康阈值,取值范围2-10,默认为2。

interval

int

探测间隔时间,取值范围1-50,默认为5。

timeout

int

探测超时时间,取值范围1-300,默认为10。

unhealthythreshold

int

不健康阈值,取值范围2-10,默认为3。

表5 routerule

参数名

类型

是否必选

说明

location

string

转发策略地址,长度不超过500,非中文。

targetgroup

string

后端集群名,长度不超过150,由字母、数字、下划线、横杠和点组成。

grayservicename

string

灰度规则

degradeurl

string

降级url

  • 不降级:undegrade
  • 默认降级:defaultdegrade

只有值为defaultdegrade时才为默认降级,其他值均认为是不降级。

configs

generalandadvancedconfigbean

通用与高级配置

表6 dynamicrouterulebean

参数名

类型

是否必选

说明

name

string

名称,长度不超过50,由字母、数字、下划线、横杠和点组成,不能包含-in-且不能以-in结尾。

switchstatus

string

开关,取值为on或off。

defaulttargetgroup

string

默认后端集群。

enablegrey

string

默认后端集群是否仍参考灰度进行分流,取值为on/off,默认为off,只有输入on才为打开状态。

rules

list<dynamicsubrulebean>

动态路由规则。

locations

list

动态路由关联的转发策略列表。

表7 dynamicsubrulebean

参数名

类型

是否必选

说明

condition

string

名称。

targetgroup

string

后端集群。

enablegray

string

是否仍参考灰度进行分流,取值为on/off,默认为off,只有输入on才为打开状态。

表8 generalandadvancedconfigbean

参数名

类型

是否必选

说明

proxyreadtimeout

int

响应超时时间,不超过10位的数字。

proxysendtimeout

int

转发超时时间,不超过10位的数字。

keepaliveswitch

string

启用长连接转发,是否keepalive。

hostswitch

string

是否透传请求头,取值为on/off,不填或者其他字符均为off。

xforwardedforswitch

string

是否追加xff。

accesslogswitch

string

是否开启access日志,取值为on/off,不填或者其他字符均为off。

proxynextupstreamswitch

string

是否在异常时尝试下一台机器,取值为on/off,不填或者其他字符均为off。

proxynextupstreamcondition

string

尝试下一台机器的场景,取值为403、404、429、500、502、503、504、error、timeout、invalid_header。

clientconnectionfreetime

int

客户端连接空闲时间,不超过10位的正整数。

proxybuffersswitch

string

开启响应缓存,取值为on/off,不填或者其他字符均为off。

proxybufferssize

string

响应缓存大小,数字 空格 k/m 组成,默认8 k。

expiresswitch

string

高级配置中expires开关,取值为on/off,不填或者其他字符均为 off。

expiressize

string

设定页面缓存时间,不缓存或一直使用缓存。可以由字母、数字、空格、 $@ - 、冒号、逗号组成,长度不超过50位。

indexpage

string

静态页面场景index页面设置,长度不超过255,非中文。

returnval

string

固定返回响应码,长度不超过255,非中文。

allowmethod

string

允许的http方法,对于转发策略有效,对于监听仅为参考,在界面新增转发策略时会继承监听的此项配置,其余场景无效,get、head、post、delete、put、options、patch、mkcol、copy、move、propfind、proppatch、lock、unlock。

nuwatraceswitch

string

消息头中透传nuwatrace相关的网元身份标识和时间戳。

command

string

高级配置,自定义参数设置。

不要直接填写转发到某个集群的名称,例如proxy_pass http://upstreamname,这样配置会使得动态加载配置失效。

nginx配置命令,非中文。

root

string

默认资源根目录,长度不超过500,非中文。

clientmaxbodysize

string

最大请求体大小,数字 空格 k/m组成。

clientbodybuffersize

string

请求体buffer大小,数字 空格 k/m 组成。

addheaders

list< generalkeyvalueconfigbean>

响应头。

setvals

list< generalkeyvalueconfigbean>

对应页面set。

proxysetheaders

list< generalkeyvalueconfigbean>

请求头。

redirects

list< generalredirectconfigbean>

重定向。

rewrites

list< generalredirectconfigbean>

重写。

转发策略模板yaml

- name: hw_test                                  // 必填项,不可修改,不可重复
  type: wisecloud::loadbalancer::slb::routerule  // 资源类型为转发策略配置
  properties:
    routes:                                     // 非必填
      - targetgroup: group1
        grayservicename: grayservce_hw
        location: /abc_hw1
        degradeurl: undegrade                  // 必填项,undegrade不降级,defaultdegrade默认降级
        configs:
          hostswitch: 'off'
          addheaders:
            - value: b
              key: aaa
          clientconnectionfreetime: 60
          rewrites:
            - source: /test
              option: break
              target: /test_hw
          proxyreadtimeout: 60
          setvals:
            - value: bbb
              key: aaa
          keepaliveswitch: 'off'
          proxybufferssize: 2 m
          expiresswitch: 'on'
          proxybuffersswitch: 'on'
          accesslogswitch: 'on'
          clientmaxbodysize: 3 k
          clientbodybuffersize: 2 k
          expiressize: 2 m
          proxynextupstreamcondition: 'error,timeout'
          proxysendtimeout: 60
          xforwardedforswitch: 'off'
          proxynextupstreamswitch: 'on'
          allowmethod: 'post,put,delete'
    targetgroups:                                // 非必填
      - protocol: http                           // 必填项
        loadbalancer:                            // 必填项,负载均衡类型
          strategy: roundrobin                   // 必填项,负载均衡策略
        healthcheck:                             // 非必填,健康检查
          path: /abc_test
          protocol: http                         // 固定项
          successcodes: '200,302'
          healthythreshold: '2'
          unhealthythreshold: '3'
          switchstatus: 'on'                     // 默认关闭,on为打开,打开时,不传其他参数均使用默认值
        name: group1                             // 必填项,并且不可重复,长度不超过150,不包含特殊字符
      - protocol: http
        loadbalancer:
          hashparam: $xxx
          strategy: protocolparam
          customparam: $xxx
        healthcheck:
          switchstatus: 'off'
        name: group2
    listenergroupname: zwx_listener1             // 必填项,slb监听名称,一个转发策略实例只能绑定一个监听实例
    dynamicroutes:                               // 非必填
      - enablegrey: 'off'
        defaulttargetgroup: group1               // 必填并且存在于targetgroups中
        name: /abc_test1_hw
        locations:
          - location: /abc_hw1
        rules:
          - targetgroup: group1
            enablegray: 'off'
        switchstatus: 'on'

相关文档

网站地图