网络
虚拟私有云 VPC
弹性公网IP EIP
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
虚拟专用网络 VPN
云连接 CC
VPC终端节点 VPCEP
企业路由器 ER
企业交换机 ESW
全球加速 GA
企业连接 EC
云原生应用网络 ANC
安全与合规
安全技术与应用
Web应用防火墙 WAF
企业主机安全 HSS
云防火墙 CFW
安全云脑 SecMaster
DDoS防护 AAD
数据加密服务 DEW
数据库安全服务 DBSS
云堡垒机 CBH
数据安全中心 DSC
云证书管理服务 CCM
威胁检测服务 MTD
认证测试中心 CTC
边缘安全 EdgeSec
应用中间件
微服务引擎 CSE
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
分布式消息服务RocketMQ版
API网关 APIG
分布式缓存服务 DCS
多活高可用服务 MAS
事件网格 EG
管理与监管
统一身份认证服务 IAM
消息通知服务 SMN
云监控服务 CES
应用运维管理 AOM
应用性能管理 APM
云日志服务 LTS
云审计服务 CTS
标签管理服务 TMS
配置审计 Config
应用身份管理服务 OneAccess
资源访问管理 RAM
组织 Organizations
资源编排服务 RFS
优化顾问 OA
IAM 身份中心
云运维中心 COC
资源治理中心 RGC
解决方案
高性能计算 HPC
SAP
混合云灾备
开天工业工作台 MIW
Haydn解决方案工厂
数字化诊断治理专家服务
云生态
云商店
合作伙伴中心
华为云开发者学堂
华为云慧通差旅
开发与运维
软件开发生产线 CodeArts
需求管理 CodeArts Req
流水线 CodeArts Pipeline
代码检查 CodeArts Check
编译构建 CodeArts Build
部署 CodeArts Deploy
测试计划 CodeArts TestPlan
制品仓库 CodeArts Artifact
移动应用测试 MobileAPPTest
CodeArts IDE Online
开源镜像站 Mirrors
性能测试 CodeArts PerfTest
应用管理与运维平台 ServiceStage
云应用引擎 CAE
开源治理服务 CodeArts Governance
华为云Astro轻应用
CodeArts IDE
Astro工作流 AstroFlow
代码托管 CodeArts Repo
漏洞管理服务 CodeArts Inspector
联接 CodeArtsLink
软件建模 CodeArts Modeling
Astro企业应用 AstroPro
CodeArts 盘古助手
华为云Astro大屏应用
计算
弹性云服务器 ECS
Flexus云服务
裸金属服务器 BMS
云手机服务器 CPH
专属主机 DeH
弹性伸缩 AS
镜像服务 IMS
函数工作流 FunctionGraph
云耀云服务器(旧版)
VR云渲游平台 CVR
Huawei Cloud EulerOS
云化数据中心 CloudDC
网络
虚拟私有云 VPC
弹性公网IP EIP
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
虚拟专用网络 VPN
云连接 CC
VPC终端节点 VPCEP
企业路由器 ER
企业交换机 ESW
全球加速 GA
企业连接 EC
云原生应用网络 ANC
CDN与智能边缘
内容分发网络 CDN
智能边缘云 IEC
智能边缘平台 IEF
CloudPond云服务
安全与合规
安全技术与应用
Web应用防火墙 WAF
企业主机安全 HSS
云防火墙 CFW
安全云脑 SecMaster
DDoS防护 AAD
数据加密服务 DEW
数据库安全服务 DBSS
云堡垒机 CBH
数据安全中心 DSC
云证书管理服务 CCM
威胁检测服务 MTD
认证测试中心 CTC
边缘安全 EdgeSec
大数据
MapReduce服务 MRS
数据湖探索 DLI
表格存储服务 CloudTable
可信智能计算服务 TICS
推荐系统 RES
云搜索服务 CSS
数据可视化 DLV
数据接入服务 DIS
数据仓库服务 GaussDB(DWS)
数据治理中心 DataArts Studio
湖仓构建 LakeFormation
智能数据洞察 DataArts Insight
应用中间件
微服务引擎 CSE
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
分布式消息服务RocketMQ版
API网关 APIG
分布式缓存服务 DCS
多活高可用服务 MAS
事件网格 EG
开天aPaaS
应用平台 AppStage
开天企业工作台 MSSE
开天集成工作台 MSSI
API中心 API Hub
云消息服务 KooMessage
交换数据空间 EDS
云地图服务 KooMap
云手机服务 KooPhone
组织成员账号 OrgID
云空间服务 KooDrive
管理与监管
统一身份认证服务 IAM
消息通知服务 SMN
云监控服务 CES
应用运维管理 AOM
应用性能管理 APM
云日志服务 LTS
云审计服务 CTS
标签管理服务 TMS
配置审计 Config
应用身份管理服务 OneAccess
资源访问管理 RAM
组织 Organizations
资源编排服务 RFS
优化顾问 OA
IAM 身份中心
云运维中心 COC
资源治理中心 RGC
区块链
区块链服务 BCS
数字资产链 DAC
华为云区块链引擎服务 HBS
解决方案
高性能计算 HPC
SAP
混合云灾备
开天工业工作台 MIW
Haydn解决方案工厂
数字化诊断治理专家服务
价格
成本优化最佳实践
专属云商业逻辑
云生态
云商店
合作伙伴中心
华为云开发者学堂
华为云慧通差旅
其他
管理控制台
消息中心
产品价格详情
系统权限
客户关联华为云合作伙伴须知
公共问题
宽限期保留期
奖励推广计划
活动
云服务信任体系能力说明
开发与运维
软件开发生产线 CodeArts
需求管理 CodeArts Req
流水线 CodeArts Pipeline
代码检查 CodeArts Check
编译构建 CodeArts Build
部署 CodeArts Deploy
测试计划 CodeArts TestPlan
制品仓库 CodeArts Artifact
移动应用测试 MobileAPPTest
CodeArts IDE Online
开源镜像站 Mirrors
性能测试 CodeArts PerfTest
应用管理与运维平台 ServiceStage
云应用引擎 CAE
开源治理服务 CodeArts Governance
华为云Astro轻应用
CodeArts IDE
Astro工作流 AstroFlow
代码托管 CodeArts Repo
漏洞管理服务 CodeArts Inspector
联接 CodeArtsLink
软件建模 CodeArts Modeling
Astro企业应用 AstroPro
CodeArts 盘古助手
华为云Astro大屏应用
存储
对象存储服务 OBS
云硬盘 EVS
云备份 CBR
高性能弹性文件服务 SFS Turbo
弹性文件服务 SFS
存储容灾服务 SDRS
云硬盘备份 VBS
云服务器备份 CSBS
数据快递服务 DES
云存储网关 CSG
专属分布式存储服务 DSS
数据工坊 DWR
地图数据 MapDS
键值存储服务 KVS
容器
云容器引擎 CCE
云容器实例 CCI
容器镜像服务 SWR
云原生服务中心 OSC
应用服务网格 ASM
华为云UCS
数据库
云数据库 RDS
数据复制服务 DRS
文档数据库服务 DDS
分布式数据库中间件 DDM
云数据库 GaussDB
云数据库 GeminiDB
数据管理服务 DAS
数据库和应用迁移 UGO
云数据库 TaurusDB
人工智能
AI开发平台ModelArts
华为HiLens
图引擎服务 GES
图像识别 Image
文字识别 OCR
自然语言处理 NLP
内容审核 Moderation
图像搜索 ImageSearch
医疗智能体 EIHealth
企业级AI应用开发专业套件 ModelArts Pro
人脸识别服务 FRS
对话机器人服务 CBS
语音交互服务 SIS
人证核身服务 IVS
视频智能分析服务 VIAS
城市智能体
自动驾驶云服务 Octopus
盘古大模型 PanguLargeModels
IoT物联网
设备接入 IoTDA
全球SIM联接 GSL
IoT数据分析 IoTA
路网数字化服务 DRIS
IoT边缘 IoTEdge
设备发放 IoTDP
企业应用
域名注册服务 Domains
云解析服务 DNS
企业门户 EWP
ICP备案
商标注册
华为云WeLink
华为云会议 Meeting
隐私保护通话 PrivateNumber
语音通话 VoiceCall
消息&短信 MSGSMS
云管理网络
SD-WAN 云服务
边缘数据中心管理 EDCM
云桌面 Workspace
应用与数据集成平台 ROMA Connect
ROMA资产中心 ROMA Exchange
API全生命周期管理 ROMA API
政企自服务管理 ESM
视频
实时音视频 SparkRTC
视频直播 Live
视频点播 VOD
媒体处理 MPC
视频接入服务 VIS
数字内容生产线 MetaStudio
迁移
主机迁移服务 SMS
对象存储迁移服务 OMS
云数据迁移 CDM
迁移中心 MGC
专属云
专属计算集群 DCC
开发者工具
SDK开发指南
API签名指南
DevStar
华为云命令行工具服务 KooCLI
Huawei Cloud Toolkit
CodeArts API
云化转型
云架构中心
云采用框架
用户服务
账号中心
费用中心
成本中心
资源中心
企业管理
工单管理
客户运营能力
国际站常见问题
支持计划
专业服务
合作伙伴支持计划
我的凭证
华为云公共事业服务云平台
工业软件
工业数字模型驱动引擎
硬件开发工具链平台云服务
工业数据转换引擎云服务

SLB实例配置

更新时间:2024-12-25 GMT+08:00
分享

本章介绍通过IaC进行SLB实例配置的管理,包括nginx.conf,url重写/重定向,内网段,降级,黑白名单,流控,其他配置以及自定义lua配置,对应的资源类型为WiseCloud::LoadBalancer::SLB::Config。

SLB实例配置

表1 SLB实例配置字段说明

参数名

是否必选

说明

instanceName

SLB实例名,长度<=50

globalConf

Nginx配置,长度<=16777215

urlResetConf

url重写重定向

innerSegmentsConf

内网段配置

degradeConf

降级配置

blackListConf

黑名单配置

vipListConf

白名单配置

flowControlConf

流控配置

confLuaConf

其他配置,不填采用默认值

customLuaConf

自定义lua配置,每个lua文件大小不得超过16KB。

样例:

- name: fgc-slb-config                             #必传,SLB配置实例名
  type: WiseCloud::LoadBalancer::SLB::Config       #资源类型为实例配置
  properties:
    instanceName: fgc-slb                          #必传,SLB实例名
    globalConf:                                    #必传,nginx配置
      $ref: 'slb_instance_config/nginx.conf'
    urlResetConf:                                  #非必传,url重写重定向配置
      $ref: 'slb_instance_config/url_reset_config.yaml#'
    innerSegmentsConf:                             #必传,内网段配置
      $ref: 'slb_instance_config/inner_segments_config.yaml#'
    degradeConf:                                   #非必传,降级配置
      $ref: 'slb_instance_config/degrade_config.yaml#'
    blackListConf:                                 #非必传,黑名单配置
      $ref: 'slb_instance_config/blacklist_config.yaml#'
    vipListConf:                                   #非必传,白名单配置
      $ref: 'slb_instance_config/viplist_config.yaml#'
    flowControlConf:                               #非必传,流控配置
      $ref: 'slb_instance_config/flow_control_config.yaml#'
    confLuaConf:                                   #非必传,其他配置
      $ref: 'slb_instance_config/conf_lua_config.yaml#'
    customLuaConf:                                 #非必传,自定义lua配置
      slb100GlobalInit: 
        $ref: 'slb_instance_config/SLB_100_Global_Init_iac3.lua'
      slb200WorkerInit:
        $ref: 'slb_instance_config/SLB_200_Worker_Init_iac3.lua'
      slb300PreFlowControl:
        $ref: 'slb_instance_config/SLB_300_Pre_FlowControl_iac3.lua'
      slb400OnFlowControled:
        $ref: 'slb_instance_config/SLB_400_On_FlowControled_iac3.lua'
      slb500PreGrey:
        $ref: 'slb_instance_config/SLB_500_Pre_Grey_iac3.lua'
      slb600PostGrey:
        $ref: 'slb_instance_config/SLB_600_Post_Grey_iac3.lua'
      slb700PostRoute:
        $ref: 'slb_instance_config/SLB_700_Post_Route_iac3.lua'
      slb750RespHeaderFilter:
        $ref: 'slb_instance_config/SLB_750_Resp_Header_Filter_iac3.lua'
      slb800RespBodyFilter:
        $ref: 'slb_instance_config/SLB_800_Resp_Body_Filter_iac3.lua'

nginx配置

slb_instance_config/nginx.conf #nginx默认配置

#user  slb slb;
worker_processes auto;
#worker_cpu_affinity 0001 0010 0100 1000;
pid        logs/nginx.pid;
#####################################################################
### Default: Close the error log
error_log  /dev/null crit;
# nofile per worker around 20000-100000 is ok, eg, if have 8 worker, nginx will use no more than 8*worker_rlimit_nofile nofile, should make this result less than system nofile.
worker_rlimit_nofile 51200;
events {
    use epoll;
    # connections per worker, usually setup same or similar value as worker_rlimit_nofile.
    worker_connections 51200;
}
http {
    #####################################################################
    ### load basic lua script
    include 'lua/nginx.http.lua.conf';
    init_by_lua_file 'conf/lua/initial.lua';
    init_worker_by_lua_file 'conf/lua/initialWorker.lua';
    log_by_lua_file 'conf/lua/monitor/LogRequest.lua';
    #rewrite_by_lua_no_postpone on;
    #####################################################################
    uninitialized_variable_warn off;
    server_tokens off;
    autoindex off;
    port_in_redirect off;
    ssi off;
    proxy_hide_header X-Powered-By;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-frame-options SAMEORIGIN;
    add_header X-Content-Type-Options  nosniff;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains ";
    add_header Content-Security-Policy "default-src 'self'";
    add_header Cache-control "no-cache, no-store, must-revalidate";
    add_header Pragma no-cache;
    add_header Expires 0;
    client_header_timeout 60s;
    client_body_timeout 60s;
    keepalive_timeout 75s;
    send_timeout 60s;
    client_header_buffer_size 1k;
    large_client_header_buffers 4 8k;
    client_body_buffer_size 16k;
    client_max_body_size 1m;
    proxy_buffer_size 8k;
    proxy_buffers 8 8k;
    proxy_busy_buffers_size 16k;
    include mime.types;
    default_type text/html;
    #####################################################################
    ### gzip compress
    gzip on;
    gzip_http_version 1.1;
    gzip_comp_level 5;
    gzip_min_length 1k;
    gzip_disable "MSIE [1-6].";
    gzip_types
        text/plain text/css text/xml text/javascript
        application/json application/x-javascript application/xml application/xml+rss application/xhtml+xml;
    #####################################################################
    ### enabled the error page  process
    fastcgi_intercept_errors on;
    error_page 400 401 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 /4xx.html;
    error_page 500 501 502 503 504 505 /5xx.html;
    #####################################################################
    ### log format and switch.
    log_format  main  '$time_local|$request_time|$upstream_response_time|$uri'
        '|$status|$body_bytes_sent|$request_length|$bytes_sent|$http_user_agent|$http_host'
        '|$upstream_addr|$upstream_status|$scheme|$is_grey_server|$resp_status|$server_protocol';
    access_log logs/access.log  main buffer=5m flush=10s;
    log_format  bigData  '$time_local|$server_addr|$upstream_addr|$is_grey_server|$uri'
        '|$upstream_status|$resp_status|$request_time|$upstream_response_time|$request_length|$bytes_sent|$connections_active|$target_all|$remote_addr'
        '|$http_x_forwarded_for|$request_method|$http_user_agent|$status|$http_referer|$server_protocol|$body_bytes_sent|$request_length|$http_host|$request'
        '|$server_port|-|$http_x_api_method||||||||||';
    access_log logs/access_for_big_data.log  bigData buffer=5m flush=10s;
    #####################################################################
    ### load sub configure
    include vhosts/*.conf;
    include slb_conf/*.conf;
}

重写重定向配置

表2 urlResetConf字段说明

参数名

类型

是否必选

说明

transferType

String

转换类型,为以下枚举值:

  • rewriteGrey 灰度重写
  • rewriteNormal 生产重写
  • redirectGrey 灰度重定向
  • redirectNormal 生产重定向

source

String

匹配路径,例:/abc/portal/login.jsp(.*)$

target

String

目标路径,例:/abc/def/$1

slb_instance_config/url_reset_config.yaml #重写重定向配置

- transferType: rewriteNormal               #必填,转发类型,rewriteNormal代表生产重写
  source: /a1                               #必填,匹配路径
  target: /b1                               #必填,目标路径
- transferType: rewriteGrey                 #必填,转发类型,rewriteGrey代表灰度重写
  source: /a2                               #必填,匹配路径
  target: /b2                               #必填,目标路径

内网段配置

表3 innerSegmentsConf字段说明

参数名

类型

是否必选

说明

segment

String

IP地址段,格式为ip/子网掩码。

slb_instance_config/inner_segments_config.yaml #内网段配置

- segment: 10.0.0.0/8               
- segment: 127.0.0.1/32
- segment: 172.16.0.0/12
- segment: 192.168.0.0/16
- segment: 100.125.0.0/16

降级配置

表4 degradeConf

参数名

类型

是否必选

说明

switchStatus

String

降级开关,取值为on或off。

degradeUrl

String

修改时必传,不传表示置空此项,取值<=500。

currentLevel

int

当前降级等级,取值为整数1到5。

defaultLevel

int

接口默认等级,取值为整数1到5。

ruleItems

List<DegradeRule>

当降级开关为on时必填

当降级开关为off时非必填

降级列表,每个等级只能有一个。

表5 DegradeRule

参数名

类型

是否必选

说明

level

String

降级等级,取值为1-5之间。

values

int

降级规则,对应等级的匹配规则表达式,例如:

path equal[/abc/def,abc/ghi]

<=100000

slb_instance_config/degrade_config.yaml #降级配置

switchStatus: 'on'                           #必填,降级开关,取值为off或on
defaultLevel: 4                              #必填,接口默认等级,取值为整数1到5
currentLevel: 3                              #必填,当前降级等级,取值为整数1到5
degradeUrl: @xxx                             #非必填,降级url
ruleItems:                                   #降级规则信息
  - level: 1                                 #必填,等级
    values: head[appid] equal[1,2,3]         #必填,降级规则
  - level: 2
    values: head[appid] equal[4,5,6]

黑白名单配置

表6 blackListConf/vipListConf字段说明

参数名

类型

是否必选

说明

switchStatus

String

开关,取值为on或off。

groups

List<BlackVipListGroup>

名单列表

degradeUrl

String

定制响应location,以@olc_degrade开头,当不传递时,表示置空该字段。

表7 BlackVipListGroup

参数名

类型

是否必选

说明

ruleItems

List<BlackVipListRule>

规则列表

表8 BlackVipListRule

参数名

类型

是否必选

说明

type

String

匹配项类型,取值为:path、left-ip、right-ip、custom。

param

String

参数名,长度<=50

Type为custom时必传,其他type无需传递。

position

String

位置

  • Type为custom时必传,为以下枚举值:queryString、header、resource、body-json、body-form。
  • 当type为path、left-ip、right-ip时无需传递。

match

String

匹配条件

  • 当type为left-ip或right-ip时,仅支持:sha256和rangeIP。
  • 当type为custom或path时,仅支持:equal、sha256、pattern。

values

String

对应匹配的值

  • match为equal时,例如填写1,2,3,表示1或2或3都可匹配。
  • 当match为rangeIP时,填写样例:

    10.1.1.1-10.1.1.100,10.2.2.1-10.2.2.100

  • match为sha256时,填写样例:5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5, 226fe7d26af82de76db083e6a29524ca68f4aaf80f2c2db058571fdb8f1fdeea
  • match为pattern时,填写样例:

    ^abc

    <=102400

slb_instance_config/blacklist_config.yaml #黑名单配置

switchStatus: 'on'                                 #必填,黑名单开关,取值为off或on
degradeUrl: @xxx                                   #非必填,降级url
groups:                                            #必填,黑名单组
  - ruleItems:                                     #必填,组内规则
    - type: custom                                 #必填,类型
      param: x-app-id                              #非必填,参数
      position: header                             #非必填,位置
      match: equal                                 #必填,匹配条件
      values: '[1,2,3]'                            #必填,值

slb_instance_config/viplist_config.yaml #白名单配置

switchStatus: 'on'                                     #必填,白名单开关,取值为off或on
groups:                                                #必填,白名单列表
  - ruleItems:                                         #必填,组内规则
    - type: custom                                     #必填,类型
      param: x-app-id                                  #非必填,参数
      position: header                                 #非必填,位置
      match: equal                                     #必填,匹配条件
      values: '[1,2,3]'                                #必填,值

流控配置

表9 flowControlConf字段说明

参数名

类型

是否必选

说明

flowControlSwitch

String

流控总开关,取值为on或off。

autoDivideSwitch

String

分摊模式开关,取值为on或off。

flowControlOrder

String

流控类型执行顺序,和下面的流控配置相匹配。

nodeFlowControl

FlowControlTypeBean

节点级流控配置

interfaceFlowControl

FlowControlTypeBean

接口级流控配置

serviceFlowControl

FlowControlTypeBean

服务级流控配置

ipFlowControl

FlowControlTypeBean

IP流控配置

singleParamFlowControl

FlowControlTypeBean

自定义参数流控配置

multiParamFlowControl

FlowControlTypeBean

多参数组合流控配置

quotaFlowControl

FlowControlTypeBean

配额流控配置

concurrentFlowControl

FlowControlTypeBean

并发连接流控配置

表10 FlowControlTypeBean

参数名

类型

是否必选

说明

switchStatus

String

流控开关,取值为on或off

degradeUrl

String

降级URL,长度<500

limit

int

每秒请求量

burst

int

突发请求量

limitTag

String

自定义标签,长度<=200

ruleItems

List<FlowControlRule>

匹配规则列表

configGroups

List<FlowControlGroup>

匹配规则组列表

表11 FlowControlRule

参数名

类型

是否必选

说明

type

String

匹配项类型,为以下枚举:path、left-ip、right-ip、custom。

param

String

参数名,长度<50。

type为custom时必传,其他type无需传递。

position

String

位置

  • type为custom时必传,以下枚举值:queryString、header、resource、body-json、body-form、url。
  • 其他type无需传递。

match

String

参数匹配方式

  • 当type为left-ip或right-ip时,仅支持:sha256和rangeIP。
  • 当type为custom或path时,仅支持:equal、sha256、pattern。

values

String

对应匹配的值

  • match为equal时,例如填写1,2,3,表示1或2或3都可匹配。
  • 当match为rangeIP时,填写样例:

    10.1.1.1-10.1.1.100,10.2.2.1-10.2.2.100

  • match为sha256时,填写样例:5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5, 226fe7d26af82de76db083e6a29524ca68f4aaf80f2c2db058571fdb8f1fdeea
  • match为pattern时,填写样例:

    ^abc

    <=102400

isAgg

String

是否聚合,0不聚合 1 聚合,默认不聚合

limit

int

limit大小

接口级流控,ip流控,服务级流控,单参数流控必填,其他类型流控无效

burst

int

突发量

接口级流控,ip流控,服务级流控,单参数流控必填,其他类型流控无效

limitTag

String

自定义标签

<=200

表12 FlowControlGroup

参数名

类型

是否必选

说明

timeWindow

int

配额周期,正整数。

timeWindow配合timeUnit,最多不超过86400秒,或不超过1440分钟,或不超过24小时,或不超过1天。

timeUnit

String

时间单位,取值为second、minute、hour、day。

limit

int

限流数量。

burst

int

突发量。

ruleItems

List< FlowControlRuleBean >

匹配规则列表。

slb_instance_config/flow_control_config.yaml #流控配置

flowControlSwitch: 'on'                            #必填,流控总开关,取值为off或on
autoDivideSwitch: 'off'                            #必填,分摊模式开关,取值为off或on
flowControlOrder: nodeFlowControl,urlFlowControl   #必填,流控类型顺序;和下面的流控配置相匹配
nodeFlowControl:                                   #非必填,节点级流控
  switchStatus: 'on'                               #必填,节点级流控开关,取值为off或on
  degradeUrl: xxx                                  #非必填,限流降级url
  limit: 1000                                      #必填,流控值
  burst: 1000                                      #必填,突发量
  limitTag: xxxx                                   #非必填,自定义标签
serviceFlowControl:                                #非必填,服务级流控
  switchStatus: 'on'
  degradeUrl: xxx
  limit: 1000
  burst: 1000
  ruleItems:                                       #必填,流控规则
    - match: equal                                 #必填,匹配条件;取值有equal,pattern
      values: example.com                          #必填,域名值
      limit: 1000                                  #必填,流控值
      burst: 1000                                  #必填,突发量
      limitTag: xxxx                               #非必填,自定义标签
interfaceFlowControl:                              #非必填,接口级流控
  switchStatus: 'on'
  degradeUrl: xxx
  limit: 1000
  burst: 1000
  ruleItems:
    - match: equal                                 #必填,匹配条件;取值有equal,pattern
      values: xxx                                  #必填,接口url
      limit: 1000                                  #必填,流控值
      burst: 1000                                  #必填,突发量
      limitTag: xxxx                               #非必填,自定义标签
      isAgg: off                                   #非必填,聚合统计开关
ipFlowControl:                                     #非必填,IP流控
  switchStatus: 'on'
  degradeUrl: xxx
  limit: 1000
  burst: 1000
  ruleItems:
    - type: left-ip                                #必填,类型
      match: rangeIP                               #必填,匹配条件
      values: 1.1.1.1-1.1.1.2                      #必填,值
      limit: 1000                                  #必填,流控值
      burst: 1000                                  #必填,突发量
      limitTag: xxxx                               #非必填,自定义标签
singleParamFlowControl:                            #非必填,自定义参数流控
  switchStatus: 'on'
  degradeUrl: xxx
  ruleItems:
    - param: xxx                                   #必填,参数
      position: url                                #必填,位置
      match: equal                                 #必填,匹配条件
      values: 1                                    #必填,值
      limit: 1000                                  #必填,流控值
      burst: 1000                                  #必填,突发量
      limitTag: xxxx                               #非必填,自定义标签
multiParamFlowControl:                             #非必填,多参数组合流控 
  switchStatus: 'on'
  degradeUrl: xxx
  configGroups:                                    #必填,配置组
    - limit: 1000                                  #必填,组流控值
      burst: 1000                                  #必填,组突发量
      limitTag: xxxx                               #非必填,自定义标签
      ruleItems:                                   #必填,流控规则
        - type: path                               #必填,类型
          param:                                   #非必填,参数
          position:                                #非必填,位置
          match: equal                             #必填,匹配条件
          values: /a                               #必填,值
          isAgg: 'off'                             #非必填,聚合统计开关
        - type: custom
          param: zzz
          position: queryString
          match: equal
          values: 1
          isAgg: off
quotaFlowControl:                                 #非必填,配额流控
  switchStatus: 'on'
  degradeUrl: @example.com
  configGroups:                                   #必填,配置组
    - timeWindow: 10                              #必填,时间周期窗口
      timeUnit: minute                            #必填,时间单位
      limit: 1000                                 #必填,配额大小
      limitTag: xxxx                              #非必填,自定义标签
      ruleItems:                                  #必填,流控规则
        - type: path                              #必填,类型
          param:                                  #非必填,参数
          position:                               #非必填,位置 
          match: equal                            #必填,匹配条件
          values: /a                              #必填,值
          isAgg: 'off'                            #非必填,聚合统计开关
        - type: custom
          param: zzz
          position: queryString
          match: equal
          values: 1
          isAgg: off
concurrentFlowControl:                           #非必填,并发连接流控 
  switchStatus: 'on'
  degradeUrl: xxx
  configGroups:                                  #必填,配置组
    - limit: 1000                                #必填,流控值
      burst: 1000                                #必填,突发量
      limitTag: xxxx                             #非必填,自定义标签
      ruleItems:                                 #必填,流控规则
        - type: path                             #必填,类型
          param:                                 #非必填,参数
          position:                              #非必填,位置
          match: equal                           #必填,匹配条件
          values: /a                             #必填,值
        - type: custom
          param: zzz
          position: queryString
          match: equal
          values: 1

其他配置

表13 confLuaConf字段说明

参数名

说明

addGreyFlag

灰度标记开关,取值为on或off。

greyTestSwitch

灰度测试开关,取值为on或off。

greyTestServiceId

灰度测试服务Id。

greyTestSwitch为on时必传。

getIpType

取IP方式,取值为1或2,1表示从左取,2表示从右取,默认为1。

isBypassOnGreyDown

灰度服务器全部宕机后,请求路由到生产开关,取值为on或off,默认为off。

areaGreyGetIpFromLeft

地域灰度IP从左侧取值开关,取值为on或off,默认为off。

greyTestQpsLimit

灰度测试每秒转发量限制,取值为1到1000。

successRateAlarmAbsThreshold

成功率告警阈值绝对值,非负浮点数,取值为0到100,默认值为90。

successRateAlarmOffsetThreshold

成功率下降告警阈值(相比1分钟前或者5分钟前),非负浮点数,取值为0到100,默认值为5。

healthCheckAlarmServerCountThreshold

健康检查不健康机器数告警阈值,正整数,默认为1,表示有1台节点不健康就会告警。

healthCheckAlarmDurationThreshold

健康检查告警持续时间阈值,非负正整数,默认为0,表示不健康主机立即告警;如果配置为1,表示发现不健康持续1分钟以上,才会告警。

concurrentFlowControlAlarmThreshold

并发请求流控告警阈值,非负整数,默认为0,表示只要发生1次流控,就会告警。

serviceFlowControlAlarmThreshold

服务级流控告警阈值,非负整数,默认0,表示只要发生1次流控,就会告警。

singleParamFlowControlAlarmThreshold

自定义参数流控告警阈值,非负整数,默认0,表示只要发生1次流控,就会告警。

multiParamFlowControlAlarmThreshold

多参数流控告警阈值,非负整数,默认0,表示只要发生1次流控,就会告警。

quotaFlowControlAlarmThreshold

配额流控告警阈值,非负整数,默认0,表示只要发生1次流控,就会告警。

manyRequestPreAlarmThreshold

请求数过多告警阈值,正整数,例如:25000,表示每个cpu每分钟平均处理达到25000请求,则触发告警。

以4C的主机为例,1分钟处理超过25000*4=100000请求,则开始告警。

manyRequestAlarmThreshold

请求数警阈值,非负整数,默认为0。

statisticsParams

统计日志参数,格式为格式为ParamName:position。

  • ParamName为参数名称。
  • Position为参数位置,取值为queryString或header。

slb_instance_config/conf_lua_config.yaml #其他配置

addGreyFlag: 'off'                                          #非必填,灰度标记开关,取值为off或on
greyTestSwitch: 'off'                                       #非必填,灰度测试开关,取值为off或on
greyTestServiceId: 123456                                   #非必填,灰度测试服务ID
isBypassOnGreyDown: 'off'                                   #非必填,宕机时路由到生产集群开关,取值为off或on
areaGreyGetIpFromLeft: 'off'                                #非必填,地域灰度IP从左取值开关 ,取值为off或on
getIpType: 1                                                #非必填,取IP方式,取值为1或2
statisticsParams:                                           #非必填,统计日志参数
greyTestQpsLimit: 1000                                     #非必填,灰度测试每秒转发量限制,取值为1到1000
manyRequestAlarmThreshold: 1000                             #非必填,请求数量告警 
successRateAlarmAbsThreshold: 90                            #非必填,成功率告警阈值,取值为0到100
successRateAlarmOffsetThreshold: 90                         #非必填,成功率下降告警阈值,取值为0到100
healthCheckAlarmServerCountThreshold: 1000                  #非必填,健康检查告警阈值
healthCheckAlarmDurationThreshold: 1000                     #非必填,健康告警持续时间阈值
concurrentFlowControlAlarmThreshold: 1000                   #非必填,并发连接流控告警阈值
serviceFlowControlAlarmThreshold: 1000                      #非必填,服务级流控告警阈值
multiParamFlowControlAlarmThreshold: 1000                   #非必填,多参数流控告警阈值
singleParamFlowControlAlarmThreshold: 1000                  #非必填,自定义参数流控告警阈值
quotaFlowControlAlarmThreshold: 1000                        #非必填,配额流控告警阈值
manyRequestPreAlarmThreshold: 1000                          #非必填,请求数量预告警

自定义lua配置

表14 customLuaConf字段说明

参数名

类型

是否必选

说明

slb100GlobalInit

String

大小不得超过16KB

slb200WorkerInit

String

大小不得超过16KB

slb300PreFlowControl

String

大小不得超过16KB

slb400OnFlowControled

String

大小不得超过16KB

slb500PreGrey

Int

大小不得超过16KB

slb600PostGrey

String

大小不得超过16KB

slb700PostRoute

String

大小不得超过16KB

slb750RespHeaderFilter

int

大小不得超过16KB

slb800RespBodyFilter

float

大小不得超过16KB

slb_instance_config/SLB_100_Global_Init_iac3.lua #SLB_100_Global_Init_iac3.lua默认配置

--the custom point SLB_100_Global_Init, running when Global init.
--will be triggered in exec function, so pls make sure there is a exec function in global_init
local global_init = {};
function global_init.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"i am in global_init")
end
return global_init

slb_instance_config/SLB_200_Worker_Init_iac3.lua #SLB_200_Worker_Init_iac3.lua默认配置

--the custom point SLB_200_Worker_Init, running when Worker init.
--will be triggered in exec function, so pls make sure there is a exec function in worker_init
local worker_init = {};
function worker_init.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"i am in worker init");
end
return worker_init

slb_instance_config/SLB_300_Pre_FlowControl_iac3.lua #SLB_300_Pre_FlowControl_iac3.lua默认配置

--the custom point SLB_300_Pre_FlowControl, running before flowcontrol and blacklist.
--will be triggered in exec function, so pls make sure there is a exec function in pre_flowcontrol
local pre_flowcontrol = {};
function pre_flowcontrol.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"I am in pre flowcontrol")
end
return pre_flowcontrol

slb_instance_config/SLB_400_On_FlowControled_iac3.lua #SLB_400_On_FlowControled_iac3.lua默认配置

--the custom point SLB_400_On_FlowControlled, running when request is flowcontrolled or blocked due to blacklist.
--will be triggered in exec function, so pls make sure there is a exec function in on_flowcontroled
local on_flowcontroled = {};
function on_flowcontroled.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"the flowcontrol type is:",gen_param.control_type)
end
return on_flowcontroled

slb_instance_config/SLB_500_Pre_Grey_iac3.lua #SLB_500_Pre_Grey_iac3.lua默认配置

--the custom point SLB_500_Pre_Grey, running before Greyrule judge.
--will be triggered in exec function, so pls make sure there is a exec function in pre_grey
local pre_grey = {};
function pre_grey.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"I am in pre grey");
end
return pre_grey

slb_instance_config/SLB_600_Post_Grey_iac3.lua #SLB_600_Post_Grey_iac3.lua默认配置

--the custom point SLB_600_Post_Grey, running after get result of greyrule.
--will be triggered in exec function, so pls make sure there is a exec function in post_grey
local post_grey = {};
function post_grey.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"I AM IN POST GREY");
end
return post_grey

slb_instance_config/SLB_700_Post_Route_iac3.lua #SLB_700_Post_Route_iac3.lua默认配置

--the custom point SLB_700_Post_Route, running after get result of routerule.
--will be triggered in exec function, so pls make sure there is a exec function in post_route
local post_route = {};
function post_route.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"I AM IN POST Route");
end
return post_route

slb_instance_config/SLB_750_Resp_Header_Filter_iac3.lua #SLB_750_Resp_Header_Filter_iac3.lua默认配置

--the custom point SLB_750_Resp_Header_Filter, running during header filter.
--will be triggered in exec function, so pls make sure there is a exec function in header_filter
local header_filter = {};
function header_filter.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"I am in header filter");
end
return header_filter

slb_instance_config/SLB_800_Resp_Body_Filter_iac3.lua #SLB_800_Resp_Body_Filter_iac3.lua默认配置

--the custom point SLB_800_Resp_Body_Filter, running during body filter.
--will be triggered in exec function, so pls make sure there is a exec function in body_filter
local body_filter = {};
function body_filter.exec(gen_param)
    --eg:ngx.log(ngx.ERR,"I am in body filter");
end
return body_filter
提示

您即将访问非华为云网站,请注意账号财产安全

文档反馈

文档反馈

意见反馈

0/500

标记内容

同时提交标记内容