Forum Discussion
thedge_91588
Nimbostratus
Dec 11, 2009Trouble 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
- The_Bhattman
Nimbostratus
Can you post up the contents of the $::redirect class object? - thedge_91588
Nimbostratus
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. - thedge_91588
Nimbostratus
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? - The_Bhattman
Nimbostratus
Yes or 192.168.1.20 / 24
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