Forum Discussion

johtte_168100's avatar
johtte_168100
Icon for Nimbostratus rankNimbostratus
Sep 28, 2015

iRule redirect to pool based on path

Hi,

 

I am migrating rules from ISA Server to F5, actually the ISA check the path and redirect to backend server for example,

 

domain.com/online -> domain.com/online/ on node01 (10.0.0.1) domain.com/-> domain.com/online/index.html on node01 (10.0.0.1) domain.com/auth -> domain.com/auth on node02 (10.0.0.2)

 

i created an iRule to check the path and redirect to asigned pool when HTTP_REQUEST { if { [HTTP::path] starts_with "/" } { http:redirect "/online/" pool pool_node01 return } if { [HTTP::path] starts_with "/online" } { pool pool_node01 return } if { [HTTP::path] equals "/online/auth" } { pool pool_node02 return } }

 

But, ihave some problems when i try to redirect to backend servers.

 

Any suggestions?

 

Regards

 

1 Reply

  • Part of your problem is order of operations and a couple syntax. Try something like this. It reorders the second two if statements to get your expected results.

    HTTP_REQUEST {
        if { [HTTP::path] equals "/" } {
            HTTP::redirect "/online/"
            return
        }
        elseif { [HTTP::path] starts_with "/online/auth" } {
            node node02 (or pool   )
            return
        }
        elseif { [HTTP::path] starts_with "/online" } {
            node node01 (or pool  member  )
            return
        }
    }