Forum Discussion
Layer 7 Application Routing?
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?
10 Replies
- Kevin_Stewart
Employee
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?
- JPV_131616
Cirrus
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 - Debbie_123533
Nimbostratus
We are on version 11. - Debbie_123533
Nimbostratus
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.
- Kevin_Stewart
Employee
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/app3You 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.
- Mike_Maher
Nimbostratus
What do you want to trigger off of - Debbie_123533
Nimbostratus
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? - Kevin_Stewart
Employee
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.
- Mike_Maher
Nimbostratus
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.
- Kevin_Stewart
Employee
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/ltmOr look at it in the GUI under System - Logs.
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