haproxy根据客户端浏览器进行跳转

本文介绍HAProxy中如何通过不同策略实现流量调度与健康检查,包括基于用户代理、访问后缀、路径匹配等方法,并详细解释了四种健康检查方式的具体配置。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
根据手机端
acl iphone hdr_sub(user-agent) -i iphone
redirect prefix   if  iphone
acl android hdr_sub(user-agent) -i android
redirect prefix   if  android
  
根据访问后缀
acl test_pic path_end .gif .png .jpg .css .js
use_backend nginxpools  if  test_pic
 
根据访问开始路径来匹配
acl test_static path_beg  /html/
  
  acl hd_dom hdr(Host) -i  test .com
  
  -i  忽略大小写
  hdr是函数
  
  method http方法
  req_ver  请求版本
  resp_ver  响应版本
  status   http状态
  url    精确匹配url
  url_reg  正则匹配
  url_dir   斜线之间
  url_dom   斜线之间或点之间
  
  在haproxy匹配的时候根据use_backend先后顺序进行匹配
  
  
  Haproxy健康检查方式
  1.基于端口的健康检查方式
  check port 80
  
  
  2.基于http的 head 的ip url健康检查方式
  option httpchk HEEAD  /health .txt HTTP /1 .0
  server web1 192.168.1.2:80 maxconn 20480 weight 8 check inter 3000 fall 2  rise2 
  
  3.基于http的get的健康检查方式
  option httpchk GET  /health .txt 
  
  4.基于具体业务域名的URL健康检查
  option httpchk HEAD  /index .jsp HTTP /1 .1\r\nHost:
  option httpchk GET  /index .jsp HTTP /1 .1\r\nHost:www. test .com 
  
  
  haproxy中backup参数的使用

wKioL1XfKvrjZADmAARc6YNE9wQ790.jpg


本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1689112


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值