Forum Discussion
iRule to select Pool
I have 2 pools that need to be access by the same url but with different jsp files. Ie. test.com/test1.jsp goes to pool 1 and test.com/test2.jsp goes to pool 2. But no other content for the site has test1.jsp or test2.jsp in the URL. Is it possible to create a iRule with or without a data group that will select a pool with on the first URL of a new session? ie if a user goes to test.com/test1.jsp and that session is directed to pool1, i need the remainder of the traffic on that session to be directed to the same pool. I've attempted different flavors of persistence and they seem to inspect every URL requested. A example of a iRule i attempted is below. Thanks in advance for the help.
when HTTP_REQUEST {
if { [HTTP::uri] contains "test1.jsp" } {
pool Test1-pool
persist cookie insert Campus-Cookie "0d 10:00:00"
} elseif { [HTTP::uri] contains "test2.jsp"} {
pool Test2-pool
persist cookie insert Campus-Cookie "0d 10:00:00"
}
}
5 Replies
- james_lee_31100
Nimbostratus
What happened after test1.jsp? After user access test1.jsp or test2.jsp, would user direct to different web page? the Irule only works if user stays on test1.jsp or test2.jsp
- CBerg64_161993
Nimbostratus
In the initial URL that a user uses will have the test1.jsp or test2.jsp. I'm looking for a way to persist to the server their initial connection is on for the remainder of the session.
- james_lee_31100
Nimbostratus
you need to add another condition in your Irule based on cookie persistency
since your test condition in your current Irule only validate test1.jsp and test2.jsp, If there is any other user session after that, it does not go through the Irule
- CBerg64_161993
Nimbostratus
Right, that i know. What i don't know is the proper way to add the additional condition to make that happen. Thanks for the help.
- Alexander_Dube_
Altocumulus
Hi,
i've just written the following. You can try this, but without any guaranty 😉
when HTTP_REQUEST { if { [HTTP::cookie exists Pool]} { switch [HTTP::cookie Pool] { "pool1" { pool Test1-pool } "pool2" { pool Test2-pool } } } else { if { [HTTP::uri] contains "test1.jsp" } { pool Test1-pool } elseif { [HTTP::uri] contains "test2.jsp"} { pool Test2-pool } } } when HTTP_RESPONSE { if { [HTTP::uri] contains "test1.jsp" } { HTTP::cookie insert name Pool value "pool1" } elseif { [HTTP::uri] contains "test2.jsp"} { HTTP::cookie insert name Pool value "pool2" } }Regards Alex
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