Forum Discussion
Load Balancing with Data Groups
I have an iRule that looks at a data group and sends the application to the correct pool based on the string defined in the data group. We are load balancing our applications between 1 - Windows 2003 pool and 1 - Windows 2012 pool so we can upgrade our application 1 and a time and move to the new server when ready. However, I'm running into an issue when there are underscores in the application name. I have to define my application in the datagroup with a backslash at the end which requires the user to type the backsplash in the URL. How do I get around this? Here is my iRule: when HTTP_REQUEST { if { [class match [string tolower [HTTP::path]] contains dwdworkweb-acc.2003]} { pool dwdworkweb-acc.2003 } else {pool dwdworkweb-acc.2012 } }
I have tried using equals instead of contains but then nothing works. So for example, http://dwdworkweb-acc/applicationone works but http://dwdworkweb-acc/application_one does not, (strings in the datagroup are defined as /applicationone and /application_one)I have to type http://dwdworkweb-acc/application_one/ in order for it to work. Any help would be greatly appreciated.
7 Replies
- Amit_Karnik
Nimbostratus
Just a though, can you add the conditional "contains" OR "end_with". I am thinking the tcl contains operator might be checking if string1 is fully contained in string2.
- Debbie_123533
Nimbostratus
That doesn't work, getting: 01070151:3: Rule [/Common/dwdworkweb-acc] error: /Common/dwdworkweb-acc:2: error: [wrong args][class match [string tolower [HTTP::path]] contains or end_with dwdworkweb-acc.2003]
- Amit_Karnik_269
Nimbostratus
Actually I tested your orginal iRule and it works for me correctly even with the case translation and an "_" in the keyword. Could you add some log statements to check your HTTP::path as well as log statements before your pool assignments.
- kunjan
Nimbostratus
How about the following iRule?
when HTTP_REQUEST { if { [class match "[string tolower [HTTP::path]]/" contains dwdworkweb-acc.2003]} { pool dwdworkweb-acc.2003 } else { pool dwdworkweb-acc.2012 } }
- Debbie_123533
Nimbostratus
Thanks everyone but I figured it out, I had to add an entry in my data group to add the %5f to replace the underscore. entries look like this now:
/test_debbie
/test%5fdebbie (added this one)
now it's working.
- Amit_Karnik_269
Nimbostratus
Thanks for posting a followup. I was curious since your base iRule was working for me. You ran into URL encoding. Something for all of us to remember for future problems as well as at design time ;-) for new iRules. http://www.w3schools.com/tags/ref_urlencode.asp
- Debbie_123533
Nimbostratus
Thank you!
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