Forum Discussion
Greg_76561
Jan 28, 2011Nimbostratus
Route to different pools based on /content
Hello,
I'm new to iRules and trying to come up with a way to send traffic to different pools based on the /content in the url.
I have a secure site which the ssl certificate is installed on the LTM and from there it is non-secure to the server.
I would like to set it up to where when a user goes to https://www.domain.com/QA they go to one pool. If a user goes to https://www.domain.com/UAT they go to a different pool and if they go to https://www.domain.com/Prod they go to a third pool. The path might actually be longer than these but we should be able to key off of QA, UAT and Prod and send it to the appropriate pool that way.
Any help would be greatly appreciated.
Thanks
Greg
15 Replies
Sort By
- Hi Greg,
profile httpclass qa_class { defaults from httpclass pool qa_pool redirect none paths { "/QA*" "/qa*" } } profile httpclass uat_class { defaults from httpclass pool uat_pool redirect none paths { "/UAT*" "/uat*" } }
when HTTP_REQUEST { Check URI set to lower case with wildcard matching switch [string tolower [HTTP::uri]] { "uat*" { uat_pool } "qa*" { qa_pool } default_pool { qeneral_pool } } }
- Thanks for all the information. That worked great but apparently I was misinformed on part of what they are wanting. They actually want the QA, UAT or Prod removed from the string when it is sent on to the pool. So if you went to https://www.domain.com/QA/Signon.jsp they want it sent to the QA pool but they want the QA removed from the string but keep everything after that.
- How about:
HTTP::uri [string range [HTTP::uri] [string first "/" [HTTP::uri] 1] end] % set uri "/QA/Signon.jsp" /QA/Signon.jsp % string range $uri [string first "/" $uri 1] end /Signon.jsp
Would there be a way to do this to just remove the QA, UAT or Prod from the url without having the full path defined within the iRule. It would be a little cleaner and easier to manage as there could be additional paths that need to get added later on and would rather not have to keep adding rules as they add additional paths.
- What do yo mean defining the path? As far as best practices go, there are trade-offs between readability and manageability. If you aren't doing too much, it makes sense to be lumped into one iRule. If there are a crazy number of lines and functions, it might make more sense to split them out.
- If, for example, today we had a client going to http://www.domain.com/QA/Signon.jsp and then a month from now development added a second link such as http://www.domain.com/QA/secondpage.jsp I would rather, if possible, to have it set up to send it on to the QA pool as http://www.domain.com/Signon.jsp and http://www.domain.com/secondpage.jsp respectively without having to modify the iRule each time they add a new path. So the iRule would just look for the QA, in this example, to know it needs to send it to the QA pool and then remove the QA from the path before it sends it on. Hopefully that makes a little more sense.
- oh, I think you misunderstood my example. After the first line, I just demonstrate the string command in a native tcl shell. This is the only thing that is actual iRule code:
- I must not be doing something right when trying to tie the two together in one iRule. How do you incorporate the two sections below in to one iRule? When I've tried combining the two it will send it on to the pool but it won't strip off the /QA.
- You'll have to put section 2 inside of each match in your switch statement, i.e.
"qa*" { qa_pool HTTP::uri [string range [HTTP::uri] [string first "/" [HTTP::uri] 1] end ] }
- Thanks Chris. I tried doing that and it did not strip out the /QA, /UAT or /Prod. The url never gets altered.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects