Forum Discussion
Persistance iRule
URL = http://alerts.company.edu/
URI needs to have persistence = http://alerts.company.edu/client/*
URI no persistence = http://alerts.company.edu/csi/*
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/client/* {
persist sticky 600
use pool athoc_pool_1
default {
HTTP::redirect http://alerts.company.edu/csi
}}}
When I apply the iRule above, the other URI stops working. Is there something I can change? Do I need to use 'persist cookie' instead of 'persist sticky'?
Thank you!
-TJ
- The_BhattmanNimbostratusHi TJ,
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/client/*" { pool athoc_pool_1 } default { persist none HTTP::redirect "http://[HTTP::host]/csi" } } }
- I used the default cookie persistence profile (insert mode) and applied the iRule you suggested. I believe persistence is working correctly, but the website reports a redirect loop:
when HTTP_REQUEST { log local0.debug "using persistence" switch -glob [string tolower [HTTP::path]] { "/client" { pool athoc_pool_1 } default { persist none HTTP::redirect "http://[HTTP::host]/csi" log local0.debug "using redirect" } } }
- I am thinking the logic would be something like the following, but need help with syntax.
when HTTP_REQUEST { log local0.debug "using persistence" if {([class match [switch -glob [string tolower [HTTP::path]] { "/client"}}] { pool athoc_pool_1 && !([string tolower [HTTP::path]] starts_with "/client")} { default { persist none HTTP::redirect "http://[HTTP::host]/csi" log local0.debug "using redirect" } } } }
- The_BhattmanNimbostratusPosted By work_hard_play_hard on 08/17/2011 12:12 PM I used the default cookie persistence profile (insert mode) and applied the iRule you suggested. I believe persistence is working correctly, but the website reports a redirect loop:
when HTTP_REQUEST { log local0.debug "using persistence" switch -glob [string tolower [HTTP::path]] { "/client" { pool athoc_pool_1 } default { persist none HTTP::redirect "http://[HTTP::host]/csi" log local0.debug "using redirect" } } }
alerts.company.edu/client and then send it over to the alternative pool. It will do a redirect if it's "http://alerts.company.edu/client/something" or"http://alerts.company.edu/client/something/something" , etc. If you use HTTP::path you are basically only seeing the path and not any query stringsFor examplethe following URL:1 http://www.example.com:8080/main/in...ogin=checkThe path is:1 /main/index.jspNote that only ? is used as the separator for the query string. So, for the following URL:1 http://www.example.com:8080/main/in...ogin=checkthe path is:1 /main/index.jsp;session_id=abcdefghAs you can see HTTP::path doesn't contain query string which is not the entire URL.So if you are okay with that you can proceed to use it. However, i would further investigate whether the loop is explicitly being caused by the webserver or the iRULE itself.
I hope this helps
Bhattman
- Kevin_Davies_40NacreousErrr...
when HTTP_REQUEST {
log local0.debug "using persistence"
switch -glob [string tolower [HTTP::path]] {
"/client" { pool athoc_pool_1 }
default {
persist none
HTTP::redirect "http://[HTTP::host]/csi"
log local0.debug "using redirect"
}
}
/client needs to have a * after it otherwise it will match anywhere in the string. "/client*"
You redirect to the same VIP with /csi so this will fall though to the redirect again hence the infinite loop.
If you really want everything that does not match /client* to be redirected to /csi then this should do it.
when HTTP_REQUEST {
log local0.debug "using persistence"
switch -glob [string tolower [HTTP::path]] {
"/client*" { pool athoc_pool_1 }
"/csi*" { persist none }
default {
HTTP::redirect "http://[HTTP::host]/csi"
log local0.debug "using redirect"
}
}
Kevin (Jarvil)
I couldn't get the persistence profile to take in the WebUI when I had the iRule in place, so I had to manually set it in the iRule and remove the persistence profile in the WebUIWorking iRule:when HTTP_REQUEST { log local0.debug "using persistence" switch -glob [string tolower [HTTP::path]] { "/client*" { persist dest_addr 600 } default { HTTP::redirect "http://[HTTP::host]/csi" log local0.debug "using redirect" } } }
Thanks to both of you for your help. I appreciate it!-TJ- The_BhattmanNimbostratusHi TJ,
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