• 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
    


    
                                        
    
  • 相关阅读:
    C文件读写函数介绍(转)
    字节存储排序:大端和小端的判别及转换
    vc++上的MFC的对象序列化和反序列化
    unicode下各种类型转换,CString,string,char*,int,char[]
    CString与std::string unicode下相互转化
    VS2010每次编译都重新编译整个工程的解决方案
    Windows下用C语言获取进程cpu使用率,内存使用,IO情况
    hadoop 安装
    python---pyc pyo文件详解
    C 高级编程 2 内存管理
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350601.html
Copyright © 2020-2023  润新知