当前位置:网站首页>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
边栏推荐
- Introduction to advanced design system (ads) 2009 RF simulation
- Apple supplier JDI plans to sell Baishan LCD plant and equipment for us $675million
- [untitled]
- MQTT over QUIC:下一代物联网标准协议为消息传输场景注入新动力
- Cout.write learning
- 云容器与云原生
- Centos8 creates wordpress+mysql error reports according to the official website of docker
- USB Type-C PD快充简介
- How to sharpen a knife simply by yourself
- Dormant for two years! Lingsheng technology's first aiot chip released: Samsung 11nm process, integrated NPU core!
猜你喜欢

Brief introduction to the principle of spectrometer II

USB Type-C 之CC线简介

MQTT over QUIC:下一代物联网标准协议为消息传输场景注入新动力

Fluent: exception handling

Cloud container and cloud native

Composition and principle of vector network analyzer (vector network)
![[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?

Detailed explanation of network RJ45 interface

What role does low code play in the digital transformation?

欧美六国最快5日达 菜鸟推出快线产品 优化“端到端”履约服务
随机推荐
Go's sleep
Yu Chengdong: Huawei is trying to cope with the US chip ban
Application of Internet of things in smart city
SMIC's net profit in the first half of the year was 1.386 billion yuan, and the n+1 process has entered the stage of customer product verification
Import the database backup of MySQL 8 into MySQL 5
.net WCF WF4.5 状态机、书签与持久化
10.8亿美元!TCL科技收购三星苏州8.5代线:未来一年产能将增长60%!
Implementation of solid transfer function (based on transfer)
Dormant for two years! Lingsheng technology's first aiot chip released: Samsung 11nm process, integrated NPU core!
Strong performance growth! Wentai technology's net profit in the first half of the year was 1.7 billion yuan, a sharp increase of 767.19% year-on-year!
Apple supplier JDI plans to sell Baishan LCD plant and equipment for us $675million
iptables防火墙端口规则配置
联发科已向美方提交申请,力求9月15日后仍可向华为供货
信号源原理简介
USB Type-C 详解
Seven steps, in-depth interpretation of data meaning
高温天气户外活动有讲究!市民盛夏健身安全指引来了
沪硅产业上半年营收8.5亿元,同比增长30.53%!各类产品认证正在加速
Five key considerations for network security budget planning in 2023
Food safety | will the salt content of bread exceed the standard? A few tips to teach you to eat bread correctly!