Forum Discussion
Application migration iRule
VIP 2.1.1.1:443 with SSL termination and cookie persistence
Old Web Pool
APP1 – 1.1.1.1:80/APP1/login.html, 1.1.1.2:80/APP1/login.html
APP2 – 1.1.1.1:80/APP2/login.html, 1.1.1.2:80/APP2/login.html
APP3 – 1.1.1.1:80/APP3/login.html, 1.1.1.2:80/APP3/login.html
New Web Pool
APP1 – 1.1.1.10:8080/APP1/login.html, 1.1.1.11:8080/APP1/login.html
APP2 – 1.1.1.10:8080/APP2/login.html, 1.1.1.11:8080/APP2/login.html
APP3 – 1.1.1.10:8080/APP3/login.html, 1.1.1.11:8080/APP3/login.html
I wrote the iRule to select the pool base on the URI as follows:
when HTTP_REQUEST {
set time_out 3600
if {[findclass
[HTTP::uri] $::old_server_pool " "] ne "" } {
pool old_server_pool-80
} elseif {[findclass [HTTP::uri]
$::new_server_pool " "] ne "" } {
pool new_server_pool-8001
}
}
It is not working as I thought
it would. The web servers are doing a
redirect from VIPIP/APP1/login.html to VIPIP/psp/APP1/?cmd=login. I have to put the redirect URI in the data group
instead of the original URI. Why isn’t
the original URI evaluated? Is there a better way of doing this?
7 Replies
- The_Bhattman
Nimbostratus
Hi Patrick, - Michael_Yates
Nimbostratus
I think that it might be because you are using findclass instead of matchclass.when HTTP_REQUEST { if { [matchclass [HTTP::uri] equals $::old_server_pool] } { pool old_server_pool-80 } elseif { [matchclass [HTTP::uri] equals $::new_server_pool] } { pool new_server_pool-8001 } }
- Patrick_McGlyn1
Nimbostratus
Sure. I should have thought to include it. I started with the following: - Patrick_McGlyn1
Nimbostratus
Michael, - The_Bhattman
Nimbostratus
Hi Patrick,class redirectapp { "/app1/login.html /psp/app1/?cmd=login" "/app2/login.html /psp/app2/?cmd=login" "/app3/login.html /psp/app3/?cmd=login" }
when HTTP_REQUEST { set uriredirected [findclass [string tolower[HTTP::uri]] $::redirectapp " "] if {$uriredirected ne "" } { HTTP::redirect "http://www.domain.com/$uriredirected" pool new_server_pool-8001 } }
- The_Bhattman
Nimbostratus
Made a correction on the codewhen HTTP_REQUEST { switch -glob [string tolower [HTTP::uri] { "/psp/app*" { pool new_server_pool-8001 } default { set redirectapp [findclass [string tolower[HTTP::uri]] $::redirectapp " "] if {$redirectapp ne "" } { HTTP::redirect "http://www.domain.com/$redirectapp" } } } }
- Patrick_McGlyn1
Nimbostratus
Thanks Bhattman. I think it should work but I am still confused. Why does the URI show up in the log as the redirect URI received from the web server and not the original URI enter by the client?
Recent Discussions
Related Content
* 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