当前位置:网站首页>haproxy实现灰度发布
haproxy实现灰度发布
2022-07-28 17:04:00 【水月清辉】
haproxy实现灰度发布
场景: 基于header头部中的depart字段信息进行灰度发布
global # 全局参数的设置
log 127.0.0.1 local2 # log语法:log <address_1>[max_level_1] # 全局的日志配置,使用log关键字,
指定使用127.0.0.1
上的syslog服务中的local0日志设备,记录日志等级为info的日志
chroot /usr/local/haproxy #改变当前工作目录
pidfile /var/run/haproxy.pid #当前进程id文件
maxconn 4000 #最大连接数
user haproxy #所属用户
group haproxy #所属组
nbproc 8
cpu-map 1 0
cpu-map 2 1
cpu-map 3 2
cpu-map 4 3
cpu-map 5 4
cpu-map 6 5
cpu-map 7 6
cpu-map 8 7
daemon #以守护进程方式运行haproxy
stats socket /var/lib/haproxy/stats
defaults
mode http #默认的模式mode { tcp|http|health },tcp是4层,http是7层,health只会返回OK
log global #应用全局的日志配置
option httplog # 启用日志记录HTTP请求,默认haproxy日志记录是不记录HTTP请求日志
option dontlognull # 启用该项,日志中将不会记录空连接。所谓空连接就是在上游的负载均衡器 或者监控系统为了探测该 服务是否存活可用时,需要定期的连接或者获取某
一固定的组件或页面,或者探测扫描端口是否在监 听或开放等动作被称为空连接;
官方文档中标注,如果该服务上游没有其他的负载均衡器的话,建议 不要使用
该参数,因为互联网上的恶意扫描或其他动作就不会被记录下来
option http-server-close #每次请求完毕后主动关闭http通道
option forwardfor except 127.0.0.0/8 #如果服务器上的应用程序想记录发起请求的客户端的IP地址, 需要在HAProxy
上 配置此选项, 这样 HAProxy会把客户端的IP信息发送给服务器,在HTTP
请求中添加"X-Forwarded-For"字 段。 启用 X-Forwarded-For,在requests
头部插入客户端IP发送给后端的server,使后端server获 取到客户端的真实IP。
option redispatch # 当使用了cookie时,haproxy将会将其请求的后端服务器的serverID插入到
cookie中,以保证 会话的SESSION持久性;而此时,如果后端的服务器宕掉
了, 但是客户端的cookie是不会刷新 的,如果设置此参数,将会将客户的请
求强制定向到另外一个后端server上,以保证服务的正常。
retries 3 # 定义连接后端服务器的失败重连次数,连接失败次数超过此值后将会将对应后端
服务器标记为不可用
timeout http-request 10s #http请求超时时间
timeout queue 1m #一个请求在队列里的超时时间
timeout connect 10s #连接超时
timeout client 1m #客户端超时
timeout server 1m #服务器端超时
timeout http-keep-alive 10s #设置http-keep-alive的超时时间
timeout check 10s #检测超时
maxconn 3000 #每个进程可用的最大连接数
listen status
bind 0.0.0.0:1080
mode http
log global
stats refresh 30s
stts uri /admin?stats
stats realm Private lands
stats auth admin:[email protected]
stats hide-version
frontend http_443_in
bind *:443 ssl crt /etc/haproxy/cert.pem
mode http
#-----------#
#acl list
acl pipeline hdr_reg(host) -i ^(www.test.com)(:443)?$
#acl gray user config
acl test_user_tag hdr_reg(x-user-name) -i ^(jdtw00000)
#acl gay depart config
acl test_depart_tag hdr_reg(depart) -i ^(ASDFSEWW51235LJL145)$
#userbackend gray user list
#use_backend backend_pipeline_test if pipeline pipeline_user_tag
#userbackend gray depart list
#use_backend backend_pipeline_test if pipeline test_depart_tag
#usebackend list
use_backend backend_pipeline if pipeline
#___________---
backend backend_pipeline
mode http
balacne roundrobin
option forwardfor
option httpchk GET /cd-test/v2/healthcheck
server test_svr_a01 12.0.2.4:8443 ssl check verify none check inter 5000 rise 2 fall 3
server test_svr_b01 12.0.2.80:8443 ssl check verify none check inter 5000 rise 2 fall 3
backend backend_pipeline_test
mode http
balacne roundrobin #负载均衡算法
option forwardfor
option httpchk GET /cd-test/v2/healthcheck
#server test_test_svr_a01 12.0.2.4:8443 ssl check verify none check inter 5000 rise 2 fall 3
#server test_test_svr_b01 12.0.2.80:8443 ssl check verify none check inter 5000 rise 2 fall 3
边栏推荐
- 余承东:华为正在想办法应对美国芯片封杀
- cout.write的学习
- The diversion between video number and official account is convenient and considerable
- ModelBox端云协同AI开发套件(RK3568)试用记录(三)
- 深圳线下报名|StarRocks on AWS:如何对实时数仓进行极速统一分析
- .net WCF WF4.5 状态机、书签与持久化
- 物联网在智慧城市的应用
- solidity的require报错
- DC-DC switching power supply
- DC simulation example of ADS simulation
猜你喜欢
![[dry goods] how to establish a close relationship between support and products?](/img/ec/bc36beb0935968fec3791910e2cb0a.png)
[dry goods] how to establish a close relationship between support and products?

2023年网络安全预算规划的五个关键考虑因素

DC simulation example of ADS simulation

Tcp/ip detailed diagram

Fluent: exception handling

#夏日挑战赛#【FFH】JS自定义组件:DIY一个随点随用的键盘!(一)

Detailed explanation of oscilloscope parameters

Introduction to oscilloscope

About the difference between root and alias under localization

连线:谁拥有未来的艺术?OpenAI允许Dall-E用户将作品商用化,目前而言
随机推荐
Andorid: pit encountered by zxing.demo QR code scanning framework
VMware virtual machine networking settings (win10 comes with virtual machine installation win7)
solidity的modifier修饰器的_;
GIS数据漫谈(六)— 投影坐标系统
cout.write的学习
欧美六国最快5日达 菜鸟推出快线产品 优化“端到端”履约服务
USB type-C details
频谱仪原理简介一
Go的walk库报错
There is a special cryptology language called asn.1
任正非最新发声:美国政治家希望华为死,求生欲使华为振奋起来
Iptables firewall port rule configuration
7-day sales of video number exceed one million
[untitled]
The video number is more like a official account of version 2.0
马斯克利用活猪展示全新脑机接口技术:可实时读取猪脑信息
syntax error: non-declaration statement outside function bodygo 和 syntax error: unexpected {, expect
Import the database backup of MySQL 8 into MySQL 5
体验5分钟开发微信小程序
美国对华为禁令开始波及欧洲芯片厂商