分享一下我老师大神的人工智能教程!零基础,通俗易懂!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