Forum Discussion

thedge_91588's avatar
thedge_91588
Icon for Nimbostratus rankNimbostratus
Dec 11, 2009

Trouble with HTTP redirect based on IP address list

Im trying to setup an iRule on a F5 BigIP load balance switch (running 9.4.7) that will redirect several IP addresses to a webpage. Im trying to prevent these IP addresses that are on the LAN from accessing anything on the website behind the BigIP, so http://sample/ or anything under it like http://sample/foo etc.

 

 

I followed a few examples I found on here and couldnt get them working like I wanted. Below is what I was trying. I have setup the datagroup, the iRule, and applied the iRule to the virtual server that handles http://sample and everything under it.

 

 

 

The below sample seemed to half work, it would increment the statistics for the iRule, saying it executed but no redirect happened when I went to http://sample/foo from an IP thats on the list.

 

 

when HTTP_REQUEST {

 

if { [matchclass [IP::client_addr] equals $::redirect] } {

 

HTTP::redirect "http://google.com"

 

}

 

}

 

 

 

This sample would redirect everything, due to the !.

 

 

when HTTP_REQUEST {

 

if { ![matchclass [IP::client_addr] equals $::redirect] } {

 

HTTP::redirect "https://google.com"

 

}

 

}

 

 

 

Can anyone help or provide insight?

 

 

Thanks

 

  • Can you post up the contents of the $::redirect class object?

     

     

     

    Bhattman

     

  • It is configured as type address and then type hostname. I only have one IP address in the list right now (the computer I was testing from), no actual hostnames.

     

     

    I was doing the testing by entering the IP of a desktop then going to the http://sample/foo URL from that desktop.
  • You know, I think I just realized my mistake.... I have it entered as "192.168.1.20" instead of "192.168.1.20 / 255.255.255.0". I assume that is what you were getting at?