zoukankan      html  css  js  c++  java
  • 多个haproxy 之间跳转

    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		
    		
    		
       
    
    
    	
    

  • 相关阅读:
    Matlab 绘制三维立体图(以地质异常体为例)
    Azure DevOps的variable group实现array和hashtable参数的传递
    Azure DevOps 利用rest api设置variable group
    Azure AADSTS7000215 其中一种问题的解决
    Power BI 实现实时更新Streaming Dataset
    AAD Service Principal获取azure user list (Microsoft Graph API)
    Matlab 沿三维任意方向切割CT图的仿真计算
    Azure Powershell script检测登陆并部署ARM Template
    Azure KeyVault设置策略和自动化添加secrets键值对
    Azure登陆的两种常见方式(user 和 service principal登陆)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350630.html
Copyright © 2011-2022 走看看