F5 iRules 設定
筆記一下
設定固定ip轉道設定的pool
when CLIENT_ACCEPTED {
if { [IP::addr [IP::remote_addr] equals 192.168.1.226/255.255.255.255] } {
pool xx_tt
} else {
pool xx_80
}
}
設定固定ip轉道設定的pool下的member主機
when CLIENT_ACCEPTED {
if { [IP::addr [IP::remote_addr] equals 192.168.1.234/255.255.255.255] } {
pool xx_80 member 192.168.1.204 80
} else {
pool xx_80
}
}
自動轉址abc網域任一網頁都轉到www.xyz.com.tw
when HTTP_REQUEST {
if { [HTTP::host] equals "abc.com.tw" }
{
HTTP::redirect "http://www.xyz.com.tw[HTTP::uri]"
}
}
指定某些網頁http轉https (強制加密)
when HTTP_REQUEST {
switch -glob [HTTP::path] {
/a01.aspx* -
/b03.aspx* -
/Member.aspx* -
/Login.aspx* -
/login.aspx*{
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
log local0. " Redirect client to https://[HTTP::host][HTTP::uri] "
}
}
}
指定某些網頁https轉http (強制不加密減輕ssl)
when HTTP_REQUEST {
switch -glob [HTTP::path] {
/abc.aspx* -
/aa12.aspx* -
/default.aspx*{
HTTP::redirect "http://[HTTP::host][HTTP::uri]"
log local0. " Redirect client to http://[HTTP::host] [HTTP::uri] "
}
}
}
檢查網頁回應狀態碼 轉到特定網址
when HTTP_RESPONSE {
switch [HTTP::status] {
"200" -
"404" -
"301" -
"302" -
"304" {
}
default {
HTTP::redirect "http://www.aaa.com.tw/error/error.html"
log local0. " Response code [HTTP::status] detected for server [IP::server_addr]"
}
}
}
檢查網址抬頭不是帶特定host就轉到 轉到特定網址
when HTTP_REQUEST {
if { not([HTTP::host] equals "www.abc.com.tw")}
{
HTTP::redirect "http://www.abc.com.tw[HTTP::uri]"
}
}