Forum Discussion
f5 irule - alternative for default required
I am new to irule creation: when HTTP_REQUEST { switch -glob [HTTP::uri] {
"/analytics*" {
pool abc.com-analytics-pool
}
"/em*" {
pool abc.com-em-pool
}
"/xmlpserver*" {
pool abc.com-analytics-pool
}
"/console*" {
pool abc.com-em-pool
}
"/va*" {
pool abc.com-analytics-pool
}
default {
HTTP::redirect https://[HTTP::host]/analytics/
}
} } when HTTP_RESPONSE { if { [HTTP::is_redirect] }{ HTTP::header replace Location [string map { "; "; } [ HTTP::header Location]] } }
this is definition of my irule problem: when URI "va" is being called first it goes to the right place "va" then default pool is also being invoked so it ends up opening wrong page "analytics" for this I have a choice of, I check why the default is being invoked unnecessarily: I don't know how can I check that
or in my default :it covers two contion 1)when the only host is being requested so only host no URI and another URI is "/" can you please confirm how can we define in irule when no URI is requested or only slash is requested so I can remove default clause from the definition- Arie
Altostratus
Your question is a bit confusing :-)
Also, per RFC the URI would include the host...
As for the default pool, I would start by configuring a default pool as part of the VIP configuration. Would that solve your problem?
- Arie
Altostratus
You didn't include all the information, but it looks like the second request (to /va) was redirected to a log-in page (/bi-security-login/login.jsp).
That third request would end up on the default pool.
However, this is getting really messy. I don't know what kind of authentication the application is using, but if you authenticate on a different server than the one you end up on it is quite possible that that server will not be aware that the user is already authenticated.
You would have to provide a lot more information before the question can be answered on DevCentral...
Before getting in too far, can you explain why you have to have different pools?
- nitass
Employee
but when a request for /va is being invoked it initially goes to the right page :bi-security login then immediately another redirection happens and then /analytics is being invoked and that page appears whereas requested was /va in browser.
can you try to change the switch's default to root?
from
default { HTTP::redirect https://[HTTP::host]/analytics/ }
to
"/" { HTTP::redirect https://[HTTP::host]/analytics/ }
- ritika_khandelw
Nimbostratus
your provided solution worked for me as well when I removed default code with : if { [HTTP::path] equals "/" } { HTTP::redirect "/analytics/" } also worked. it worked for me but I could not get a clue why the default was the problem : if you have that understanding,request you to explain.
- nitass_89166
Noctilucent
but when a request for /va is being invoked it initially goes to the right page :bi-security login then immediately another redirection happens and then /analytics is being invoked and that page appears whereas requested was /va in browser.
can you try to change the switch's default to root?
from
default { HTTP::redirect https://[HTTP::host]/analytics/ }
to
"/" { HTTP::redirect https://[HTTP::host]/analytics/ }
- ritika_khandelw
Nimbostratus
your provided solution worked for me as well when I removed default code with : if { [HTTP::path] equals "/" } { HTTP::redirect "/analytics/" } also worked. it worked for me but I could not get a clue why the default was the problem : if you have that understanding,request you to explain.
- nitass
Employee
I could not get a clue why the default was the problem : if you have that understanding,request you to explain.
http_request event is executed on every single http request. the /bi-security-login/... was checked and the default action was taken. that is why you got the redirection response.
rule of thumb is to make condition the most specific as possible.
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