Hello, I am extremely new to F5 and iRules and I have NO programming background. I need to create an iRule that will load balance our applications between 2003/2008 servers. Currently, we have about 200 applications under our main url on a windows 2003 server and as we migrate applications over to 2008, I need an easy way to loadbalance at the application level. Is there a way I can setup an irule that would use a data group or a table of some sort that as I migrate the application over to 2008, I could just update the table/data group? If so, how do I do it?
So you have 200 applications running on a single 2003 web server? Are you doing host header redirection, or do they all have separate IP addresses?
Yes you can! What version of firmware are you on? You can redirect traffic to different servers using an iRule which checks the datagroup for / vs /app2 for example… cheers
We are on version 11.
Yes. No host header redirection, they are all using the same IP Address. Example below:
http://mymainurl http://mymainurl/app1 http://mymainurl/app2 http://mymainurl/app3 etc.
Okay then. Since all of the applications live under different URIs of the same host. Example:
www.example.com/app1
www.example.com/app2
www.example.com/app3
You could build a data group that maps URIs to pools. Example:
Datagroup (ex. my_uri_dg):
"/app1" := "app1_2003_pool"
"/app2" := "app2_2003_pool"
"/app3" := "app3_2003_pool"
"/app4" := "app4_2003_pool"
"/app5" := "app5_2003_pool"
And then an iRule like this:
when HTTP_REQUEST {
if { [class match [string tolower [HTTP::uri]] starts_with my_uri_dg] } {
pool [class match -value [string tolower [HTTP::uri]] starts_with my_uri_dg]
}
}
You’ll need to create a separate pool for each application, and then when you want to upgrade an app, simply create the new pool and modify the datagroup entry.
What do you want to trigger off of
The application URI. For example, I have a main site with 200 apps http://mainsite.com http://mainsite.com/app1 http://mainsite.com/app2 http://mainsite.com/app3 etc. And as I migrate app1 over to Windows 2008, I just want to update one table or datagroup that has already been setup. So when I’m ready to flip the switch I just need to add app1 to my list and it will know to route it over to my 2008 pool. Does that make sense?
when I create my data group, my options are address, string, integer and external file
You’d use a string-based data group.
Also, wouldn’t I only need two pools? One for 2003 and one for 2008?
I didn’t process this at first, but yes - one pool for each.
Debbie - If you want an easy way out go to Local Traffic > Profiles > Protocol >HTTP Class. You can create a class and assign URIs and a pool to it, you should be able to do one for the 2008 URI’s and one for the 2003 URI’s then assign both to the Virtual Server in question.
Skipping down to the answer section so that I can properly format the code.
OK, I get the jist of all of this but the first part isn’t working, only the else is working… Can you see what I did wrong? I have /app1:=Windows2008Pool defined in my_uri_dg when HTTP_REQUEST { if { [class match [string tolower [HTTP::uri]] starts_with my_uri_dg]} { pool [class match -value [string tolower [HTTP::uri]] starts_with my_uri_dg] } else {pool Windows2003 } }
Since the else is working, that leads me to believe the condition isn’t being met. Throw in some logging:
HTTP_REQUEST {
log local0. "Original URI = [HTTP::uri]"
if { [class match [string tolower [HTTP::uri]] starts_with my_uri_dg] } {
log local0. "URI matches datagroup"
pool [class match -value [string tolower [HTTP::uri]] starts_with my_uri_dg]
} else {
log local0. "URI doesn't match data group"
pool Windows2003
}
}
You can either tail the LTM log in the BIG-IP management shell:
tail -f /var/log/ltm
Or look at it in the GUI under System - Logs.