This should be easy
Okay, I am a total noob here and I'm trying to figure out my first iRule. I've spent the better part of yesterday looking for examples to plagiarize and I found one that looked perfect for what I am wanting to do but it doesn't seem to work for me.
Go easy on me because I am sure this is the worst way to do this but okay.
What I have is a single VIP that goes to five different pools based on part of the URL. However, I want to strip out part of the URL before sending it to the pools.
So my URLs are basically this:
receptionservice.company.com/hangar1/services/reception
receptionservice.company.com/hangar2/services/reception
receptionservice.company.com/hangar3/services/reception
receptionservice.company.com/hangar4/services/reception
receptionservice.company.com/hangar5/services/reception
I want to strip out the /hangar out of the URL.
My first try was I build five HTTP Class Profiles to look at the pattern string for the "/hangar" part and for when it sees the correct hangar, send it to the pool that matches (the pools are called hangar1 through hangar5, just so you know).
That didn't work because the server folks are not expecting nor do they want to deal with the /hangar part of the URL - they only want what follows.
So I added to my HTTP Class Profiles with that option at the very bottom - Rewrite URI. I thought I was brilliant. Except that the URL can var after the "/services" part, sometimes they want "/reception" sometimes they want "/reception?wsdl". It doesn't seem like the the Rewrite URI option allows for the * wildcard - at least I couldn't get it to work.
Anyway, now I am thinking of an iRule. Here is what I have:
when HTTP_REQUEST {
log local0. "Initial [HTTP::uri]"
Check the HTTP path with wildcards
switch -glob -- [HTTP::uri] {
/hangar?/HTTP::uri "[HTTP::uri]"
}
log local0. "Rewritten [HTTP::uri]"
}
Here are the log results:
Wed Feb 13 07:22:49 CST 2013 info local/tmm1 tmm1[8353] Rule URL_rewrite_Hangar : Rewritten /hanger2/services/reception
Wed Feb 13 07:22:49 CST 2013 info local/tmm1 tmm1[8353] Rule URL_rewrite_Hangar : Initial /hanger2/services/reception
Wed Feb 13 07:22:49 CST 2013 info local/tmm tmm[8352] Rule URL_rewrite_Hangar : Rewritten /hanger2/services/reception
Wed Feb 13 07:22:49 CST 2013 info local/tmm tmm[8352] Rule URL_rewrite_Hangar : Initial /hanger2/services/reception
Wed Feb 13 07:22:49 CST 2013 info local/tmm1 tmm1[8353] Rule URL_rewrite_Hangar : Rewritten /hanger2/services/reception
Wed Feb 13 07:22:49 CST 2013 info local/tmm1 tmm1[8353] Rule URL_rewrite_Hangar : Initial /hanger2/services/reception
Any idea what I am missing?
Thanks!