• haproxy redirect location和redirect prefix


    <pre name="code" class="html">redirect location <loc> [code <code>] <option> [{if | unless} <condition>]
    redirect prefix   <pfx> [code <code>] <option> [{if | unless} <condition>]
    redirect scheme   <sch> [code <code>] <option> [{if | unless} <condition>]
      Return an HTTP redirection if/unless a condition is matched
      May be used in sections :   defaults | frontend | listen | backend
                                     no    |    yes   |   yes  |   yes
    
      If/unless the condition is matched, the HTTP request will lead to a redirect
      response. If no condition is specified, the redirect applies unconditionally.
    
      如果/除非 条件被匹配,HTTP 请求会导致重定向响应。如果没有条件被指定, 重定向无条件应用
      
      Arguments :
        <loc>     With "redirect location", the exact value in <loc> is placed into
                  the HTTP "Location" header. When used in an "http-request" rule,
                  <loc> value follows the log-format rules and can include some
                  dynamic values (see Custom Log Format in section 8.2.4).
    			  
    			  使用重定向位置, 准确的值在<loc> 是被放入到HTTP"Location" header.
    			  
    			  用于"http-request" rule,
    			  
    			  <loc> 值 遵循 log-format rules 包含一些动态值
    			  
                     mode http
        acl being_scanned be_sess_rate gt 100
        redirect location /denied.html if being_scanned
    	
    	#用法三、当用户访问172.16.1.100时,重定向到http://www.afwing.com
    acl  dstipaddr  hdr(Host) 172.16.1.100
    redirect  location   http://www.afwing.com if  dstipaddr
    	
    
         acl host_wx.cn  hdr(Host)  120.55.118.6
         redirect location  http://wechatTest.winfae.com/index.html if host_wx.cn
     
     
     访问  120.55.118.6 跳转到http://wechatTest.winfae.com/index.html
    
    		  重定向到一个路径
    		  
    		  
      
    			  
    			  
        <pfx>     With "redirect prefix", the "Location" header is built from the
                  concatenation of <pfx> and the complete URI path, including the
                  query string, unless the "drop-query" option is specified (see
                  below). As a special case, if <pfx> equals exactly "/", then
                  nothing is inserted before the original URI. It allows one to
                  redirect to the same URL (for instance, to insert a cookie). When
                  used in an "http-request" rule, <pfx> value follows the log-format
                  rules and can include some dynamic values (see Custom Log Format
                  in section 8.2.4).
    			  
    			  重定向前缀,the "Location" header是建立在<pfx> 相关的和完整的URI 路径,
    			  
    			  
    			  包含查询的字符串,除非  "drop-query"选项被指定(参见下面)
    			  
    			  
    			  作为一个特殊的例子, 如果 <pfx> 等于 /,那么什么业不会插入在原始的URI前。
    			  
    			  它会允许重定向到相同的URL(比如,插入cookie).
    			  
    			  当使用在 http-request 规则, <pfx> 遵循 log-format
                  rules
    			  
    			  和 包含一些动态值
    			          acl short_dom hdr(Host) -i etiantian.org
                         redirect prefix http://php.etiantian.org code 301 if short_dom
                       目的:使访问http://etiantian.org 跳转到http://php.etiantian.org
    			  
    			  
    			  
    		
              acl host_wx2.cn  hdr(Host) -i  wechatTest.winfae.com
             redirect prefix  http://wechatTest.winfae.com/index.html if host_wx2.cn
    
    
    		 
    			  
    	http://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/	  
    			  
    			  
    	原因 wechatTest.winfae.com 匹配到这个就重定向到http://wechatTest.winfae.com/index.html ,导致写了多个Index.html
    


    
                                        
    
  • 相关阅读:
    TIMESTAMP类型字段在SQL Server和MySQL中的含义和使用
    Redis阻塞诊断基础
    MySQL分区表
    Redis 主从复制
    Redis安全以及备份还原
    Redis物理文件结构
    Redis的Errorlog或者启动日志(错误日志)的配置
    Redis 编译安装
    MySQL自增列锁模式 innodb_autoinc_lock_mode不同参数下性能测试
    SQL Server并发操作单个表时发生在page页面级的死锁
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350601.html
Copyright © 2020-2023  润新知