Forum Discussion

flefranc_29890's avatar
flefranc_29890
Icon for Nimbostratus rankNimbostratus
Nov 05, 2008

http 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

  • You can use pool command, the help is at:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/pool.html
  • 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

     

  • Just create another pool with only the member you want in it and use the pool command to select that one.

     

     

    Denny
  • 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
  • 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

     

     

  • 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]" ]

     

  • 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