多个haproxy 之间跳转

摘要:
C:˃pingwechatTest.winfae.com正在PingwechatTest.winfae.com[120.55.118.6]具有32字节的数据:来自120.55.118.6的回复:字节=32时间=5msTTL=54来自120.55.118.6的回复:字节=32时间=4msTTL=54指向120.55.118.6的haproxy机器120.55.118.6haproxy默认全部转发到8
C:>ping wechatTest.winfae.com

正在 Ping wechatTest.winfae.com [120.55.118.6] 具有 32 字节的数据:
来自 120.55.118.6 的回复: 字节=32 时间=5ms TTL=54
来自 120.55.118.6 的回复: 字节=32 时间=4ms TTL=54


指向120.55.118.6的haproxy机器

120.55.118.6haproxy 默认全部转发到8088

###匹配wechatTest.winfae.com 开头的

####判断用户访问如果主机名以www开头的话则标示为host_www
####acl host_www  hdr_beg(host) -i www

 acl             hmq_6_req               hdr_beg(host)           -i                      wechatTest.winfae.com
        
 use_backend     wechatTest.winfae.com             if                                    hmq_6_req              
		
		

backend  wechatTest.winfae.com
        mode            http
        balance         roundrobin
        server          hmq_host_80             115.236.160.83:8088     check inter 2000 fall 3 weight 20
		
		
 115.236.160.83 映射到内网的192.168.32.82
       default_backend webserver_8088



192.168.32.82 在跳转到192.168.32.16	   
	   
backend webserver_8088
        mode            http
        balance         roundrobin
        server          webhost01_8001          192.168.32.16:80     check inter 2000 fall 3



192.168.32.16上的配置:
      acl             wxtest_6_req             hdr_beg(host)           -i                      wechatTest.winfae.com
        acl             url_static_zjdev        path_end                .html .gif .png .jpg .css .js
        use_backend     www.guozhenshi.com          if                      wxtest_6_req              url_static_zjdev

         acl             wxtest_1_req               hdr_beg(host)           -i                     wechatTest.winfae.com
        acl             url_web_wxtest             path_beg                -i                      /web
        use_backend     appserver_8081          if                      wxtest_1_req               url_web_wxtest

        acl             wxtest_2_req               hdr_beg(host)           -i                     wechatTest.winfae.com
        acl             url_business_wxtest        path_beg                -i                      /business
        use_backend     appserver_8081           if                      wxtest_2_req               url_business_wxtest

        acl             wxtest_3_req               hdr_beg(host)           -i                     wechatTest.winfae.com
        acl             url_validcode_wxtest       path_beg                -i                      /validcode
        use_backend     appserver_8081           if                      wxtest_3_req               url_validcode_wxtest

        acl             wxtest_4_req               hdr_beg(host)           -i                     wechatTest.winfae.com
        acl             url_api_wxtest             path_beg                -i                      /api
        use_backend     appserver_8082          if                      wxtest_4_req               url_api_wxtest

        acl             wxtest_5_req               hdr_beg(host)           -i                     wechatTest.winfae.com
        acl             url_pay_wxtest             path_beg                -i                      /pay
        use_backend     appserver_8083          if                      wxtest_5_req               url_pay_wxtest



  

  测试:
  
  jrhdpt11:/root/sbin# curl https://wechattest.winfae.com/web/noauth?method=%2Fproduct%2Ftype%2Fall%2Fzhongjun&_=1467186118610
[1] 27887
You have new mail in /var/spool/mail/root
jrhdpt11:/root/sbin# {"data":[{"code":1,"value":"至信系列"},{"code":2,"value":"活动专享"},{"code":3,"value":"鎏金系列"}],"retCode":"0000","retMsg":"查询成功"}


  

发现2个问题:

1.http://wechattest.winfae.com/index.html 不跳https


在wx03 上没有配置  redirect scheme https if !{ ssl_fc }




2.https://wechattest.winfae.com/ 访问返回503 Service Unavailable


Jun 29 15:59:36 localhost haproxy[1153]: 192.168.32.82:39666 [29/Jun/2016:15:59:36.972] http http/<NOSRV> -1/-1/-1/-1/0 503 212 - - SC-- 2/2/0/0/0 0/0 "GET / HTTP/1.1"
Jun 29 15:59:43 localhost haproxy[1153]: 192.168.32.82:39687 [29/Jun/2016:15:59:43.466] http http/<NOSRV> -1/-1/-1/-1/0 503 212 - - SC-- 2/2/0/0/0 0/0 "GET / HTTP/1.1"
Jun 29 15:59:45 localhost haproxy[1153]: 192.168.32.82:39692 [29/Jun/2016:15:59:45.115] http http/<NOSRV> -1/-1/-1/-1/0 503 212 - - SC-- 2/2/0/0/0 0/0 "GET / HTTP/1.1"
Jun 29 15:59:46 localhost haproxy[1153]: 192.168.32.82:39698 [29/Jun/2016:15:59:46.665] http http/<NOSRV> -1/-1/-1/-1/0 503 212 - - SC-- 2/2/0/0/0 0/0 "GET / HTTP/1.1"
Jun 29 15:59:52 localhost haproxy[1153]: 192.168.32.82:39715 [29/Jun/2016:15:59:52.019] http www.guozhenshi.com/gzs_host_80 0/0/0/1/1 304 238 - - ---- 0/0/0/0/0 0/0 "GET /index.html HTTP/1.1"
Jun 29 15:59:52 localhost haproxy[1153]: 192.168.32.82:39716 [29/Jun/2016:15:59:52.079] http www.guozhenshi.com/gzs_host_80 0/0/0/2/2 304 238 - - ---- 0/0/0/0/0 0/0 "GET /resources/css/base.css?_v=${last.updated} HTTP/1.1"
Jun 29 15:59:52 localhost haproxy[1153]: 192.168.32.82:39717 [29/Jun/2016:15:59:52.097] http www.guozhenshi.com/gzs_host_80 0/0/0/2/2 304 238 - - ---- 3/3/3/3/0 0/0 "GET /resources/css/index.css?_v=${last.updated} HTTP/1.1"
Jun 29 15:59:52 localhost haproxy[1153]: 192.168.32.82:39718 [29/Jun/2016:15:59:52.098] http www.guozhenshi.com/gzs_host_80 0/0/0/1/2 304 238 - - ---- 2/2/2/2/0 0/0 "GET /resources/plugins/mCustomScrollbar/jquery.mCustomScro


查看haproxy 配置:

   acl host_winfae.com  hdr_beg(host)  -i  wechatTest.winfae.com
        redirect prefix   https://wechatTest.winfae.com/index.html if  host_winfae.com
		
		
会跳成https://wechattest.winfae.com/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/



    acl wiki hdr_reg(host) -i wechatTest.winfae.com
        redirect location https://wechatTest.winfae.com/index.html  code 301 if wiki


hdr_beg(host) 匹配主机名开头

acl bbs       hdr_reg(host) -i ^(bbs.test.com|forum.test.com)  #使用正则匹配


     acl wiki hdr_reg(host) -i wechatTest.winfae.com
        redirect location https://wechatTest.winfae.com/index.html  code 301 if wiki		
		
		
   


	

免责声明:文章转载自《多个haproxy 之间跳转》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇vuex基础知识总结Docker 搭建开源 CMDB平台 之 “OpsManage”下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

openssh交叉编译

下载源码包: openssh http://www.openssh.com/portable.html openssl http://www.openssl.org/source zlib    http://www.zlib.net/ 推荐版本:zlib-1.2.11.tar.gz,openssl-1.0.2q.tar.gz,openssh-8.2p1....

yaml,json,ini这三种格式用来做配置文件优缺点

适合人类编写:ini > toml > yaml > json > xml > plist可以存储的数据复杂度:xml > yaml > toml ~ json ~ plist > ini 作者:赵扶摇链接:https://www.zhihu.com/question/41253282/answer/1198...

function邮件php smtp邮件发送代码

最近研究function邮件,稍微总结一下,以后继续补充: <?php error_reporting(E_ALL ^ E_NOTICE); ##########服务器参数设置################ $smtpserver = "smtp.163.com";//SMTP服务器 $smtpserverport = 25;//SMTP服务器端口...

成功解决问题:ModuleNotFoundError: No module named 'paddle'或者 No module named 'paddle.fluid'

安装paddle: 在pycharm输入:pip install paddle -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com  需要按要求安装common、dual、tight、data、prox模块          按要求装完common、dual、tight 、d...

Mac-VM迁移注意事项

1.迁移之后首先查看mac的网关是多少: 先cd /Library/Preferences/VMware Fusion/vmnet8 然后 cat nat.conf ip 172.16.190.2就是我的网关,你的和我的应该不一致 2.配置虚拟机中的网络 点击系统-首选项-网络连接。 配置你的网卡,我的是eth1. 地址就是你的这台虚拟机ip,网关和dn...

nginx+tomcat负载均衡搭建

一、      单独部署tomcat和nginx Nginx版本:nginx-1.13.5 Tomcat版本:apache-tomcat-8.5.8 操作系统:win10 必须先部署一个tomcat服务器。Tomcat服务器部署好后,登录tomcat服务器:localhost:8080 显示如下界面,说明部署成功。关于tomcat的部署就不详细介绍了。  ...