I’m a new user of BIGIP and TCL so please forgive me for the possibly obvious post. Would someone please provide some guidance on what I am doing wrong? Getting all kinds of errors when attempting import.
Requirements:
-Client requests http://x.com/a and is redirected to http://y.com/a without the client seeing the change
-Reverse proxy based on URI’s that are redirected to a pool
-Based on the presence of a cookie different URI redirects are available.
when HTTP_REQUEST {
HTTP::header replace Host: y.com
set cookie_exists [HTTP::cookie exists WHITECHOCOLATE]
set requested_URI [string tolower [HTTP::uri]]
if {$cookie_exists=="True"} {
switch -glob $requested_URI} {
"/a" {
pool POOLA
}
"/b" {
pool POOLB
}
"/c" {
pool POOLB
}
"/d*" {
pool POOLA
}
elseif {$cookie_exists=="False"} {
switch -glob $requested_URI} {
/a" {
pool POOLA
}
"/b" {
pool POOLB
}
"/c" } {
pool POOLB
}
}
I scrapped some code together and though I would pass it on.
when HTTP_REQUEST {
set requested_URI [string tolower [HTTP::uri]]
HTTP::header replace Host: abc.insidecompany.com
if {[HTTP::cookie exists "test"]} {
if { $requested_URI contains "/ltm" or $requested_URI starts_with "ltm" } {
log local0. "Cookie test exists, redirecting to $requested_URI pool POOLA"
pool POOLA
} elseif {$requested_URI contains "/gtm" or $requested_URI starts_with "gtm" } {
log local0. "Cookie test exists, redirecting to $requested_URI pool POOLA"
pool POOLA
} elseif { $requested_URI contains "/F5" or $requested_URI starts_with "F5" } {
log local0. "Cookie test exists, redirecting to $requested_URI pool POOLB"
pool POOLB
}
}
else {
if { $requested_URI contains "ltm" or $requested_URI starts_with "ltm" } {
log local0. "Cookie test does not exist, redirecting to $requested_URI pool POOLA"
pool POOLA
} elseif { $requested_URI contains "F5" or $requested_URI starts_with "F5" } {
log local0. "Cookie test does not exist, redirecting to $requested_URI pool POOLB"
pool POOLB
}
}
}
when HTTP_RESPONSE {
HTTP::header replace Host: abc.outsidecompany.com
}