f5 irules

1.插入XFF  

when HTTP_REQUEST {
    if { [HTTP::header exists X-Forward-For] } {
        set old_xff  [HTTP::header values X-Forwarded-For]
        HTTP::header remove X-Forwarded-For
        HTTP::header insert X-Forwarded-For_Org "[IP::client_addr],$old_xff"
    } else {
        HTTP::header insert X-Forwarded-For [IP::client_addr]
    }
}

2.重定向

  1)a.xin.com、a.youxin.com均重定向到https://a.youxin.com/owa  

when HTTP_REQUEST {
    if { ([string tolower [HTTP::host]] equals "a.xin.com") and ([HTTP::uri] equals "/") } {
        HTTP::redirect https://a.youxin.com/owa
}elseif { ([string tolower [HTTP::host]] equals "a.youxin.com") and ([HTTP::uri] equals "/") } {
        HTTP::redirect https://a.youxin.com/owa
    } else {
        HTTP::redirect https://[HTTP::host][HTTP::uri]
    }
    }

  2)多域名下,只单域名http重定向到https  

  需求:域名a.xin.com和b.xin.com都解析到1.1.100.21。目前a.xin.com和b.xin.com都是通过http访问。

  现需要将访问包含a.xin.com的http访问都转到https,同时b.xing.com保持不变。  

when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "a.xin.com" } {
        HTTP::redirect https://[HTTP::host][HTTP::uri]
    } 
    }
原文地址:https://www.cnblogs.com/xinghen1216/p/9913872.html