30-Mar-2022 07:47
My F5 has one virtual server for all URL's. I need to set a pool based on one of two matching URL's and a matching URI. the code below is what I am trying, the F5 gives me error everytime I try to update the irule.. it doen not like "else or Elseif"
when HTTP_REQUEST {
set host [string tolower [HTTP::host]]
set uri [string tolower [HTTP::uri]]
if { $host contains ".x." } {
if { $uri starts_with "/new" }
{pool "X_NEW"}
}
Else
if { $host contains ".y." } {
if { $uri starts_with "/new" }
{ pool "Y_NEW"}
}
}
31-Mar-2022 23:01
Please also post error you get, I am suspecting syntax error.
01-Apr-2022 06:14 - edited 01-Apr-2022 06:18
01070151:3: Rule [/Common/KTN_ROUTER] error: /Common/KTN_ROUTER:30: error: [missing a script after "if"][ ]
/Common/KTN_ROUTER:32: error: [undefined procedure: pool "X_NEW"][{pool "X_NEW"}]
/Common/KTN_ROUTER:34: error: [undefined procedure: Else][Else]
/Common/KTN_ROUTER:38: error: [missing a script after "if"][ ]
/Common/KTN_ROUTER:40: error: [undefined procedure: pool "Y_NEW"][{ pool "Y_NEW"}]
when HTTP_REQUEST {
set host [string tolower [HTTP::host]]
set uri [string tolower [HTTP::uri]]
if { $host contains ".x." } {
if { $uri starts_with "/new" }
{pool "X_NEW"}
}
Else
if { $host contains ".y." } {
if { $uri starts_with "/new" }
{ pool "Y_NEW"}
}
}
08-Apr-2022 10:09
Hi I would like to sent solution that relate about your requirement, Please find the irules below,
when HTTP_REQUEST {
set httphost [string tolower [HTTP::host]]
set httpuri [string tolower [HTTP::uri]]
if { ($httphost contains "x1") && ($httpuri starts_with "/y1") } {
pool pool1
} elseif { ($httphost contains "x2") && ($httpuri starts_with "/y2") } {
pool pool2
} else {
pool pool3
}
}
Please find detail of irules in link below,
https://cloud-ttrust.com/f5-irules-check-http-host-and-uri/