Forum Discussion
Domai_23823
Nimbostratus
May 11, 2018Delete URI after pool is selected - iRule
Hello All,
So I was asked to come up with an iRule to accomplish below-
URI based pool+port selection, delete the uri and send it to the selected pool+port, subsequent connections should also go to...
Stanislas_Piro2
Cumulonimbus
May 13, 2018Hi,
try this code:
when CLIENT_ACCEPTED {
set inject_cookie 0
set site_mode "default"
}
when HTTP_REQUEST {
set host [string tolower [HTTP::host]]
set uri [string tolower [HTTP::uri]]
switch -glob $host {
"app.example.com" {
if { $uri starts_with "/apple/ui" } {
HTTP::uri [string map -nocase {"/apple/ui/" "/" "/apple/ui" "/"} [HTTP::uri]]
set inject_cookie 1
set site_mode "apple"
} elseif { $uri starts_with "/android/ui" } {
HTTP::uri [string map -nocase {"/android/ui/" "/" "/android/ui" "/"} [HTTP::uri]]
set inject_cookie 1
set site_mode "android"
} elseif {[HTTP::cookie exists site_mode]}{
set site_mode [HTTP::cookie value site_mode]
}
switch $site_mode {
"apple" {pool apple_9887_pool}
"android" {pool andriod_7889_pool}
"default" {pool apple_andriod_default_pool}
}
}
}
}
when HTTP_RESPONSE {
if {$inject_cookie} {
switch $site_mode {
"apple" {
HTTP::cookie remove site_mode
HTTP::cookie insert name site_mode value apple path "/"
HTTP::cookie expires site_mode 300 relative
HTTP::cookie secure site_mode enable
set inject_cookie 0
}
"android" {
HTTP::cookie remove site_mode
HTTP::cookie insert name site_mode value android path "/"
HTTP::cookie expires site_mode 300 relative
HTTP::cookie secure site_mode enable
set inject_cookie 0
}
"default" {
HTTP::cookie remove site_mode
HTTP::cookie insert name site_mode value deleted path "/"
HTTP::cookie expires site_mode 0 absolute
HTTP::cookie secure site_mode enable
set inject_cookie 0
}
}
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects