haproxy 页面重定向 域名跳转

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               
<pre name="code" class="sql">redirect location <to> [code <code>] <option> [{if | unless} <condition>]redirect prefix   <to> [code <code>] <option> [{if | unless} <condition>] 重定向,相当于rewrite###########acl 开始了############ acl bbs       hdr_reg(host) -i ^(bbs.test.com|forum.test.com)  #使用正则匹配 acl bbs_path  path_beg -i /bbs                #url 目录 acl youxi     path_beg -i /youxi               acl static    path_end -i .html .css .js      #url 结尾文件 acl php       path_end -i .php  acl jsp       path_end -i .jsp .do   use_backend bbs_pool if bbs or bbs_path       #注意 "or"  use_backend youxi_pool if youxi use_backend static_pool if static  use_backend php_pool if php use_backend jsp_pool if jsp default_backend www.test.com                 ###########acl 结束了############  #当满足host_zjcap.cn的策略,跳转(重定向)到http://www.zjcap.cn acl host_zjcap.cn  hdr_beg(host)  -i (zjcap.cn|zhongjunziben.com)  redirect prefix   http://www.zjcap.cn if host_zjcap.cn分类: LINUX在邮件列表看到有个人问haproxy能否在接到一个请求时选择一个后端服务器,然后301重定向url 。主要原因是他有5个1G的出口,这样就能充分利用其带宽。测试了一下是可以的frontend free        bind *:80        default_backend lvs2backend lvs2        mode http        option forwardfor header ORIG_CLIENT_IP        server free174 10.253.3.16:8081 redir http://free71-174-st.inner.net:8081 weight 10 rise 3 fall 5 check inter 2000         server free173 10.253.3.15:8081 redir http://free71-173-st.inner.net:8081 weight 10 rise 3 fall 5 check inter 2000      当输入负载均衡机器的域名后,url会直接变成http://free71-17(3|4)-st.inner.net:8081.   acl monitor hdr_beg(host) -i monitor.test.com    #定义ACL名称(monitor),对应的请求的主机头是monitor.test.com  acl bbs       hdr_reg(host) -i ^(bbs.test.com|forum.test.com)  #使用正则匹配   acl host_zjcap.cn  hdr_beg(host)  -i zjcap.cn        acl host_zjzc.cn  hdr_beg(host)  -i zhongjunziben.com        redirect prefix   http://www.zjcap.cn if host_zjcap.cn        redirect prefix   http://www.zjcap.cn if host_zjzc.cnfrontend localhost    bind *:80    bind *:443 ssl crt /etc/ssl/xip.io/xip.io.pem    redirect scheme https if !{ ssl_fc }    mode http    default_backend nodes上面,我们添加了 redirect 导向,如果连接不是通过SSL连接的,它将 http 重定向到 https  acl host_zjcap.cn  hdr_beg(host)  -i zjcap.cn  acl host_zjzb.cn  hdr_beg(host)  -i zhongjunziben.com        acl www_zjzb.cn  hdr_beg(host)  -i www.zhongjunziben.com        acl host_zjzc.cn  hdr_beg(host)  -i zhongjunzichan.com        acl www_zjzc.cn  hdr_beg(host)  -i www.zhongjunzichan.com        redirect prefix   http://www.zjcap.cn if host_zjcap.cn        redirect prefix   http://www.zjcap.cn if host_zjzb.cn        redirect prefix   http://www.zjcap.cn if www_zjzb.cn        redirect prefix   http://www.zjcap.cn if host_zjzc.cn        redirect prefix   http://www.zjcap.cn if www_zjzc.cn访问 zhongjunziben.com 和 zhongjunzichan.com 跳转到  http://www.zjcap.cn 


            

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
这里写图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值