For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

sundogbrew's avatar
sundogbrew
Icon for Altocumulus rankAltocumulus
Feb 23, 2017

Irule for just redirecting traffic

Hey guys, came across some examples of redirecting based on IP address. I want to say this group of IPs gets redirected to this URL and that group of IPs gets redirected to that URL. I don't want a pool or proxy, I just want to redirect. This is what I have so far but I think I am missing something?

when HTTP_REQUEST {
if { [class match [IP::remote_addr] equals $::My_Subnets] } {
  HTTP::redirect "https://site1.com"
} else 
    {HTTP::redirect "https://site2.com"
}
}

any help you can lend is greatly appreciated! Thanks Joe

2 Replies

  • Try:

    when HTTP_REQUEST {
    if { [class match [IP::remote_addr] equals My_Subnets] } {
      HTTP::redirect "https://site1.com"
    } else {
      HTTP::redirect "https://site2.com"
    }
    }
    

    Edit: Removed $ from data group name.

  • What version are you on? The $:: for datagroups was deprecated a while back, so if you are on v11+ then you don't need that when referencing the datagroup. You would also want IP::client_addr vs remote_addr