Forum Discussion
jtostado_47719
Nimbostratus
Oct 21, 2009BIGIP 4.5 to 9.3.1 iRule Conversion
I need help converting this rule:
if (http_uri ends_with one of portal_redirect_class) {
redirect to "https://psp-portal.com/portal/server.pt"}
else {
use pool SHAREPOINT
}
27 Replies
- The_Bhattman
Nimbostratus
Did you create the CLASS object called eligibility?
Bhattman - Sams_88783
Nimbostratus
Hello Battman,
No luck still its giving me error.
I doubt that its becuase of class
I removed the class option and tried still i am getting error.
Please help - The_Bhattman
Nimbostratus
I think there is an extra brace at the end of the codewhen HTTP_REQUEST { if {[IP::addr[IP::client_addr] equals 10.1.1.1] } { if { [matchclass [string tolower [HTTP::uri]] contains $::eligibility] } { pool POOL_230_2 } else { pool POOL_230_1 } } elseif {[IP::add [IP::client_addr] eq 10.1.1.8] } { pool POOL_230_ALL } else { switch [HTTP::method] { "GET" { log local0. "GET method used" } "POST" { log local0. "POST method used"} default { log local0. "Unexpected method used" } } if { [matchclass [string tolower [HTTP::uri]] contains $::eligibility ]} { pool POOL_230_2 log local0. "Eligibility request made." } elseif { [matchclass [string tolower [HTTP::uri]] ends_with $::images ]} { pool POOL_230_ALL log local0. "Image request Made" } else { pool pool_230_1 log local0. "Generic Request Made" } } }
I hope this helps
Bhattman - Sams_88783
Nimbostratus
Hello Battman,
I am getting the following error
line 1: [undefined procedure: class] [class eligibility
line 24: [braces are required around the expression] [when HTTP_REQUEST {
line 51: [command is not valid in the current scope] [}]
Please help - The_Bhattman
Nimbostratus
Hi Sumod,
You are on the right track of how to define a class on the F5.
Here is what the class would look like on the configuration file where the class is a string.class eligibility { "/fauxpro" "/fauxpro/false/" }
Bhattman - Sams_88783
Nimbostratus
Hi Battman,
I just checked the Class MemberEligibility configuration and found as....
Class MemberEligibility > ClassType: String > class members > /fauxpro (and somemore with /fauxpro/false etc etc)
Could you please help me in converting the rule exactly according to this - The_Bhattman
Nimbostratus
Duh....I forgot about "contains one of operator" is for classes.
Then the code would be re-written asclass eligibility { "somethingsomething" } class images { ".jpg" ".gif" } when HTTP_REQUEST { if {[IP::addr[IP::client_addr] equals 10.1.1.1] } { if { [matchclass [string tolower [HTTP::uri]] contains $::eligibility] } { pool POOL_230_2 } else { pool POOL_230_1 } } elseif {[IP::add [IP::client_addr] eq 10.1.1.8] } { pool POOL_230_ALL } else { switch [HTTP::method] { "GET" { log local0. "GET method used" } "POST" { log local0. "POST method used"} default { log local0. "Unexpected method used" } } if { [matchclass [string tolower [HTTP::uri]] contains $::eligibility ]} { pool POOL_230_2 log local0. "Eligibility request made." } elseif { [matchclass [string tolower [HTTP::uri]] ends_with $::images ]} { pool POOL_230_ALL log local0. "Image request Made" } else { pool pool_230_1 log local0. "Generic Request Made" } } } }
I hope this helps
Bhattman - Sams_88783
Nimbostratus
I dont think so...because when i checked in Classes option i had found an entry "MemberEligibility" "String" some URL's mentioned over there.
In 9.x how we will do it in the same way.
Please help me with this - The_Bhattman
Nimbostratus
Hi Sumod,
I suppose it would look more or less something like this untested codewhen HTTP_REQUEST { if {[IP::addr[IP::client_addr] equals 10.1.1.1] } { if { [string tolower [HTTP::uri]] contains "memberelegibility" } { pool POOL_230_2 } else { pool POOL_230_1 } } else if {[IP::add [IP::client_addr] eq 10.1.1.8] } { pool POOL_230_ALL } else { switch [HTTP::method] { "GET" { log local0. "GET method used" } "POST" { log local0. "POST method used"} default { log local0. "Unexpected method used" } } switch [string tolower [HTTP::uri]] { "*membereligibility* { pool POOL_230_2 log local0. "Eligibility request made." } "*images" { pool POOL_230_ALL log local0. "Image request Made" } default { pool pool_230_1 log local0. "Generic Request Made" } } } }
I hope this helps
Bhattman - Sams_88783
Nimbostratus
Please help me with this also...i tired but its giving me error
if (client_addr == 10.1.1.1 netmask 255.255.255.255) {
if (http_uri contains one of MemberEligibility) {
use pool POOL_230_2
}
else {
use pool _POOL_230_1
}
}
else if (client_addr == 10.1.1.8 netmask 255.255.255.255) {
use pool POOL_230_ALL
}
else {
log "Using generic rule. Unexpected IP: ${client_addr}"
if (http_method == "GET") {
log "GET method used."
}
else if (http_method == "POST") {
log "POST method used."
}
else {
log "Unexpected method used."
}
if (http_uri contains one of MemberEligibility) {
use pool POOL_230_2
log "Eligibility request made."
}
else if (http_uri ends_with one of images) {
use pool POOL_230_ALL
log "Image request made."
}
else {
use pool POOL_230_1
log "Generic request made."
}
}
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
