Forum Discussion
skarpovi_111573
Nimbostratus
Mar 25, 2008Redirect based on the source IP
Folks, can anyone help.
i need something like this:
when HTTP_REQUEST {
if { [TCP::local_port] eq "80" } """ and source IP = 10.x.x.x"""" then redirect to
{
HTTP::redirect "https://[HTTP::host][HTTP::uri]AAA-link1"
}
if { [TCP::local_port] eq "80" } """ and source IP = all others"""
then redirect to
{
HTTP::redirect "https://[HTTP::host][HTTP::uri]BBB-link2"
}else {
pool eRoom-Servers-Pool
}
}
- Nicolas_Menant
Employee
Hi,when HTTP_REQUEST { if {([TCP::local_port] eq "80") AND ([IP::client_addr] eq "10.x.x.x") } { HTTP::redirect "https://[HTTP::host][HTTP::uri]AAA-link1" } elseif {[TCP::local_port] eq "80" } { HTTP::redirect "https://[HTTP::host][HTTP::uri]BBB-link2" } else { pool eRoom-Servers-Pool } }
- skarpovi_111573
Nimbostratus
here is the error i'm getting - Nicolas_Menant
Employee
This code complie on my bigip, after if you still have issue, i would recommend to use the iRule editor which will help you to troubleshoot syntaxwhen HTTP_REQUEST { if {([TCP::local_port] eq "80") and ([IP::client_addr] eq "10.2.3.4")} { HTTP::redirect "https://[HTTP::host][HTTP::uri]AAA-link1" } elseif {[TCP::local_port] eq "80" } { HTTP::redirect "https://[HTTP::host][HTTP::uri]BBB-link2" } else { pool eRoom-Servers-Pool } }
- skarpovi_111573
Nimbostratus
tried to play with brackets - fixed some errors, but still have some: - skarpovi_111573
Nimbostratus
i'm looking for multiple IP's as a source, not a single IP - Nicolas_Menant
Employee
if it's multiple with the same first digits then change: - skarpovi_111573
Nimbostratus
Thanks for help. works with single IP, will try with multiple - Nicolas_Menant
Employee
Glad to hear that ! - Nat_Thirasuttakorn
Employee
you may try IP::addr (see examples) - Nicolas_Menant
Employee
Sorry forgot the matchclass wiki page:
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