fdjhj 发表于 2015-8-28 08:33:34

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

根据手机端
acl iphone hdr_sub(user-agent) -i iphone
redirect prefixif iphone
acl android hdr_sub(user-agent) -i android
redirect prefixif 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 2rise2

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参数的使用



页: [1]
查看完整版本: haproxy根据客户端浏览器进行跳转