Forum Discussion
Parsing URI to Make Pool Selection
URL: www.example.com/ws/test.asmx
If URI contains "/ws/test.asmx"
If source IP address equals Pool A data list
Use Pool A
Log the request was permitted from source IP address
If source IP address equals Pool B data list
Use Pool B
Log the request was permitted from source IP address
Else
Drop request
Log the request was denied from source IP address
Here is what I have so far, but it seems that all requests are going to pool A. Any help would be greatly appreciated.
when HTTP_REQUEST {
if { [string tolower [HTTP::path]] contains "/ws/test.asmx" } {
if { ([matchclass [IP::client_addr] equals poolA-AllowList])} {
use pool poolA
log local0. "Permitted: [IP::client_addr][IP::client_addr] --> [HTTP::header host][HTTP::uri]"
if { ([matchclass [IP::client_addr] equals poolB-AllowList])} {
use pool poolB
log local0. "Permitted: [IP::client_addr][IP::client_addr] --> [HTTP::header host][HTTP::uri]"
} else {
discard
log local0. "Denied: [IP::client_addr] --> [HTTP::header host][HTTP::uri]"
}
}
}
}
- Michael_YatesNimbostratusHi Eric,
when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains "/ws/test.asmx" } { if { ([matchclass [IP::client_addr] equals poolA-AllowList])} { pool pool.fi.dev.gmacmbond.com.7172 log local0. "Permitted: [IP::client_addr] --> [HTTP::host][HTTP::uri]" } if { ([matchclass [IP::client_addr] equals poolB-AllowList])} { pool pool.fi.dev.gmacsolutions.com.7173 log local0. "Permitted: [IP::client_addr] --> [HTTP::host][HTTP::uri]" } else { discard log local0. "Denied: [IP::client_addr] --> [HTTP::host][HTTP::uri]" } } }
- Eric_FrankenfieNimbostratusThanks! I am currently running v10.2
- Eric_FrankenfieNimbostratusWe finally were able to schedule time to test this, however all did not go according to plan.
when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains "/ws/test.asmx" } { if { ([matchclass [IP::client_addr] equals poolA.AllowList])} { pool poolA log local0. "Permitted: [IP::client_addr] --> [HTTP::host][HTTP::uri]" } if { ([matchclass [IP::client_addr] equals poolB.AllowList])} { pool poolB log local0. "Permitted: [IP::client_addr] --> [HTTP::host][HTTP::uri]" } else { discard log local0. "Denied: [IP::client_addr] --> [HTTP::host][HTTP::uri]" } } }
is not being evaluated properly. I took all entries out of both 'Data Group List' and I still am able to get to the page. In addition, I checked /var/log/ltm and there are no entries for this iRule.if { [string tolower [HTTP::path]] contains "/ws/test.asmx" }
- Eric_FrankenfieNimbostratusI just ran another test after modifying the iRule to test the HTTP path, match the IP address in the first list, and log the result. This test was successful. Here is the iRule...
when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains "/ws/test.asmx" } { if { ([matchclass [IP::client_addr] equals poolA.AllowList])} { pool poolA log local0. "Permitted: [IP::client_addr] --> [HTTP::host][HTTP::uri]" } }
- Eric_FrankenfieNimbostratusI could not get the nested if statements to work. However, by creating two separate iRules, and applying each to the VS, I was able to get the logic to work.
when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains "/ws/test.aspx" } { if { ([matchclass [IP::client_addr] equals poolA.AllowList])} { use pool poolA log local0. "Permitted (poolA): [IP::client_addr][IP::client_addr] --> [HTTP::header host][HTTP::uri]" } } }
when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains "/ws/test.asmx" } { if { ([matchclass [IP::client_addr] equals poolB.AllowList])} { use pool poolB log local0. "Permitted (poolB): [IP::client_addr][IP::client_addr] --> [HTTP::header host][HTTP::uri]" } else { discard log local0. "Denied (poolA and poolB): [IP::client_addr] --> [HTTP::header host][HTTP::uri]" } } }
- Eric_FrankenfieNimbostratusStrike that last post!
- Michael_YatesNimbostratusHi Eric,
when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains "/ws/test.asmx" } { if { [class match [IP::client_addr] equals poolA.AllowList] } { log local0. "Permitted: [IP::client_addr] --> [HTTP::host][HTTP::uri]" pool poolA HTTP::redirect "http://www.google.com" } elseif { [class match [IP::client_addr] equals poolB.AllowList] } { log local0. "Permitted: [IP::client_addr] --> [HTTP::host][HTTP::uri]" pool poolB HTTP::redirect "http://www.yahoo.com" } else { log local0. "Denied: [IP::client_addr] --> [HTTP::host][HTTP::uri]" discard HTTP::redirect "http://www.msn.com" } } }
- Eric_FrankenfieNimbostratusSolved!
- Eric_FrankenfieNimbostratusSolved!
when HTTP_REQUEST { if { [string tolower [HTTP::path]] contains "/ws/test.aspx" } { if { ([matchclass [IP::client_addr] equals poolA.AllowList])} { use pool poolA log local0. "Permitted (poolA): [IP::client_addr] --> [HTTP::header host][HTTP::uri]" } elseif { ([matchclass [IP::client_addr] equals poolB.AllowList])} { use pool poolB log local0. "Permitted (poolB): [IP::client_addr] --> [HTTP::header host][HTTP::uri]" } else { discard log local0. "Denied (poolA/poolB): [IP::client_addr] --> [HTTP::header host][HTTP::uri]" } } }
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