Forum Discussion
dkraut_23236
Nimbostratus
Sep 02, 2008newbie needs irule help....
ok, I'm completely new to irules so break out the coloring book and crayons for me! lol.
I'm trying to create a rule that takes the incoming URI from the client and appends a number to the end of the host and then forwards to the corresponding pool member. For example, John Doe sends a request to http://bmcmtr:5282
and then the F5 adds a 01 to this request and forwards to pool member 01 as > http://bmcmtr01
The next request does the same thing except it is forwarded to 02 and the next to 03 and the next to 04.
The irule below generates "wrong args" errors when I attempt to create it. Am I completely off base here? Thanks!
when HTTP_REQUEST {
if { ([HTTP::host] eq "BMCMTR:5282") } {
HTTP::host "BMCMTR01:5282"
pool HTTP_pool member 10.1.1.14 80
}
if { ([HTTP::host] eq "BMCMTR:5382") } {
HTTP::host "BMCMTR02:5282"
pool HTTP_pool member 10.1.1.15 80
}
if { ([HTTP::host] eq "BMCMTR:5382") } {
HTTP::host "BMCMTR03:5282"
pool HTTP_pool member 10.1.1.16 80
}
if { ([HTTP::host] eq "BMCMTR:5382") } {
HTTP::host "BMCMTR04:5282"
pool HTTP_pool member 10.1.1.17 80
}
}
}
10 Replies
- Colin_Walker_12Historic F5 AccountIt sounds like you're trying to implement a counter, of sorts, and update the hostname with the value of the counter and then forward to a pool based on that number, resetting it every fourth pass or so. Does that sound about right?
Colin - dkraut_23236
Nimbostratus
For whatever reason, they require that a number be appended to the host name before sending it to the server. I was basically trying to accomplish that while also load balancing. It doesn't have to happen in any set order. User 1 can be sent to server03 and user 4 can be sent to server01, etc. - Patrick_Chang_7Historic F5 AccountYou can set up a normal pool and choose whatever load balancing method you want. The iRule would be something like this:
when LB_SELECTED {
use [LB::server addr] to figure out what server was selected so you can do your string replacement logic on the host name
HTTP::header replace "Host"
} - dkraut_23236
Nimbostratus
Thanks pchang. So if I add in my data (assuming pool members were 10.1.1.1 thru 10.1.1.4) Would the rule look like this?
when LB_SELECTED {
use [LB::10.1.1.1]
HTTP::header replace "Host"
}
when LB_SELECTED {
use [LB::10.1.1.2]
HTTP::header replace "Host"
}
when LB_SELECTED {
use [LB::10.1.1.3]
HTTP::header replace "Host"
}
when LB_SELECTED {
use [LB::10.1.1.4]
HTTP::header replace "Host"
} - dkraut_23236
Nimbostratus
Posted By pchang on 09/02/2008 8:00 PM
You can set up a normal pool and choose whatever load balancing method you want. The iRule would be something like this:
when LB_SELECTED {
use [LB::server addr] to figure out what server was selected so you can do your string replacement logic on the host name
HTTP::header replace "Host"
}
ok, after playing around, I don't think this will work. I need to add different replacement strings depending on which pool member the request will be sent to.
For example, if the LB is going to send the request to pool member 01 (servername01), I need it to change the host header to servername01. If it is going to send it to pool member 02, I need it to change the host header to servername02. If it is going to send it to pool member 03, I need it to change the host header to servername03. If it is going to send it to pool member 04, I need it to change the host header to servername04. Does that make sense?
Thanks! - dkraut_23236
Nimbostratus
Hi nmenant, thanks for the reply.
We're running BIG-IP 9.1.2 Build 40.6
I'm new to F5/irules and am not sure what you mean by >
"(datagroup definition you can retrieve in the bigip.conf file)"
Do I have to create or edit this file? Can I do that from the GUI or does it have to happen via CLI? - hoolio
Cirrostratus
You can create a datagroup in the GUI under Local Traffic >> iRules >> Datagroups tab >> Create. If you install the iRule editor (Click here) you can create a datagroup from the Tools | Datagroup Editor menu.
Aaron - dkraut_23236
Nimbostratus
ok all, thanks for all the replies. After numerous iterations, etc. I've come up with the following rule. However, one of our guys took a look at this and could not understand how it would actually load balance? Will this dog hunt?
when HTTP_REQUEST {
if { ([HTTP::host] eq "BMCMTR:5282") } {
HTTP::header replace "Host" "BMCMTR01:5282"
pool bmcmtr member 10.1.1.14 80
}
if { ([HTTP::host] eq "BMCMTR:5382") } {
HTTP::header replace "Host" "BMCMTR02:5282"
pool bmcmtr member 10.1.1.15 80
}
if { ([HTTP::host] eq "BMCMTR:5382") } {
HTTP::header replace "Host" "BMCMTR03:5282"
pool bmcmtr member 10.1.1.16 80
}
if { ([HTTP::host] eq "BMCMTR:5382") } {
HTTP::header replace "Host" "BMCMTR04:5282"
pool bmcmtr member 10.1.1.17 80
}
} - The_Bhattman
Nimbostratus
A couple of things
- HTTP::host never returns the PORT informatio
- You don't have an IF-ELSEIF-ELSE statement so the evaluation is going to be perform on each conditional IF statement regardless if you meet the condition.
- You are directing the traffic to a member in a pool; so no this will not load balance.
Hope this helps
CB - dkraut_23236
Nimbostratus
Posted By cmbhatt on 09/09/2008 3:07 PM
A couple of things
- HTTP::host never returns the PORT informatio
- You don't have an IF-ELSEIF-ELSE statement so the evaluation is going to be perform on each conditional IF statement regardless if you meet the condition.
- You are directing the traffic to a member in a pool; so no this will not load balance.
Hope this helps
CB
any thoughts on how to manipulate it so that it will load balance? It's functional now... it returns the web site when you access the VPP. Thanks!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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