Forum Discussion
iRule not hitting default pool?
Hi Guys, I have created an iRule to select a pool based on the URL the user goes to.
testurl.com goes to pool_group1
testurl.com/diagnostics/* goes to pool_group2
The testurl.com/diagnostics/* works fine, however the testurl.com doesn't seem to work at all when the iRule is applied to the Virtual Server. Is there something I'm missing?
14 Replies
- Kai_M__48813
Cirrus
it could be because you are searching on http::path, but im not 100% about this. But i have made a suggestion, that takes a slightly different approach:
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "diagnostics"} { pool pool_group2 persist source_adr 255.255.255.255 1800 } else { pool pool_group1 } }Hai Kai, 😉
or[HTTP::uri]
are in this specific scenario almost interchangeable. And adding a[HTTP::path]
command is always a good idea if endusers are involved... 😉[string tolower]Cheers, Kai
- Kai_M__48813
Cirrus
yeah..was a bit unsure about that...so i just used http::uri out of old habit, and probably a lack of coffee:D
string tolower should almost be mandatory, if you ask me..has saved me countless hours of troubleshooting, because of end users using capital letters when typing in the url..
- phipse
Altostratus
Something seems to be wrong with the syntax?
Please see error below
/CCRegressionTEST/irule_CCdiagnosticsimages_redirect:4: error: ["invalid argument source_adr; expected syntax spec: (add|carp|cookie|delete|dest_addr|hash|lookup|msrdp|none|simple|sip|source_addr|ssl|sticky|uie|universal) "][persist source_adr 255.255.255.255 1800 ]
Hi phipse,
you iRule looks absolutely valid^^
For testing purposes you may try to the iRules below and then take a look to your logfiles...
Test1: Forwarding every request to pool_group1
when HTTP_REQUEST { log local0.debug "iRule executed..." pool pool_group1 }Test2: Same as your iRule with added logging
when HTTP_REQUEST { log local0.debug "Debug: iRule executed..." switch -glob -- [HTTP::uri] { "/diagnostics/*" { log local0.debug "Debug: Hit the /diagnostics path." persist source_addr 255.255.255.255 1800 pool pool_group2 } default { log local0.debug "Debug: Hit the default path" pool pool_group1 } } }Cheers, Kai
- Hectorm
Nimbostratus
add the following to the irule to see what are we getting back from the server
when HTTP_RESPONSE {
log local0.debug "server Status respose [HTTP::status] if you get 301 or 302 is a redirect, 4XX are authentication and page not found, 200 good respose from the server" log local0.debug "Http::header [HTTP::header names ] " log local0.debug "header location [HTTP::header Location]"}
add the following to the irule to see what are we getting back from the server
when HTTP_RESPONSE {
log local0.debug "server Status respose [HTTP::status] if you get 301 or 302 is a redirect, 4XX are authentication and page not found, 200 good respose from the server" log local0.debug "Http::header [HTTP::header names ] " log local0.debug "header location [HTTP::header Location]"}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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