Forum Discussion
flefranc_29890
Nimbostratus
Nov 05, 2008http redirection to an IP address of a pool member
Hello,
I want to redirect all http traffic to a VIP address to the IP address of a member of a pool.
I begin like this in a i-rule :
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::redirect http://Pool}
}
It does'nt work ...I don't now how to write the IP address of the pool member chosen at a moment in a load-balancing way.
Sincerely
7 Replies
- hwidjaja_37598
Altostratus
You can use pool command, the help is at:
http://devcentral.f5.com/wiki/default.aspx/iRules/pool.html - flefranc_29890
Nimbostratus
Hello,
I have seen it but the IP address change each time because a different member is chosen in the pool then how to re-write the url ?
http://pool[member ]
Sincerely - dennypayne
Employee
Just create another pool with only the member you want in it and use the pool command to select that one.
Denny - hoolio
Cirrostratus
If you really want to redirect the client to the selected pool member's IP address, you can use a rule like this (Click here๐when LB_SELECTED { Check if requested URI is / if {[HTTP::uri] eq "/"}{ Send redirect with the selected server's IP address HTTP::redirect "http://[LB::server addr]" } }
Aaron - flefranc_29890
Nimbostratus
I try this :
when HTTP_REQUEST {
if {[IP::addr [LB::server addr] equals "10.64.21.157"]} {
HTTP::redirect http://10.64.21.157 }
}
I have a log error :
TCL error: irule_Autoconf2_Rewrite HTTP_REQUEST - bad IP address format while executing IP::addr [LB::server addr] equals 10.64.21.157 - flefranc_29890
Nimbostratus
when i try this :
when LB_SELECTED {
if {[HTTP::uri] eq "/"}{
HTTP::redirect "http://[LB::server addr]"
}
}
I get line 3: [command is not valid in current event context (LB_SELECTED)] [HTTP::redirect "http://[LB::server addr]" ] - hoolio
Cirrostratus
Sorry about that. It looks like HTTP:: commands won't work in LB_SELECTED. Else, you should be able to use LB::select to force a pool member selection and then redirect to the selected IP:when HTTP_REQUEST { set pool_info [LB::select] log local0. "The LB choice is: $pool_info. Redirecting to http://[getfield $pool_info " " 4]" Redirect to selected pool member's IP address HTTP::redirect "http://[getfield $pool_info " " 4]" }
Aaron
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