Forum Discussion

Greg_Hammond's avatar
Greg_Hammond
Icon for Nimbostratus rankNimbostratus
Mar 24, 2020

irule for url redirect based on client ip

I have the following irule on a VIP that is listening on port 80. The developers now need the same (or similar) irule to work on the same VIP listening on port 443. The only real difference is what port the VIP is listening on and the default pool. I tried applying this irule to the port 443 VIP but it doesn't work.

 

when HTTP_REQUEST {

  if { 

  ( [IP::addr [IP::client_addr] equals 10.32.96.0/20] ) 

 or ( [IP::addr [IP::client_addr] equals 10.32.128.0/20] ) 

 } {

HTTP::redirect https://m.eocsubmissionsdev.us.mycompany.com[HTTP::uri]

  } else {

pool eocsubmissions3_80-pool

  }

}

 

What am I missing?

1 Reply

  • ​you can write something like below. . Just i have corrected the parameter.

    when HTTP_REQUEST {
        if { ( [IP::addr [IP::client_addr] equals 10.32.96.0/20] ) or ( [IP::addr [IP::client_addr] equals 10.32.128.0/20] ) } {
            HTTP::redirect "https://m.eocsubmissionsdev.us.mycompany.com[HTTP::uri]"
        } elseif {
    	pool eocsubmissions3_80-pool
        }
    }