Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

iRule for specific redirect

Hi, I got problem with preparing iRule uri redirect for specific servers.

Situation looks like:

  • S1 - serve two websites: /activ-admin and /activ-app
  • S2 - serve one website: /activ-app

On F5 i try to achive situation where:

  • VIP_IP/activ-app will forward to S1/activ-app
  • VIP_IP/activ-app2 will forward to S2/activ-app
  • VIP_IP/activ-admin will forward to S1/activ-admin

Now I write something like this:

when HTTP_REQUEST {
set start_uri [string tolower [HTTP::uri]]
    if { $start_uri starts_with "/activ-app2" } {
        HTTP::uri [string map { "app2" "app" } [HTTP::uri]]
        pool pool member 10.0.0.2 8080
        return
    } elseif { $start_uri starts_with "/activ-app" } {
        pool pool member 10.0.0.1 8080
    } elseif { $start_uri starts_with "/activ-admin" } {
        pool pool member 10.0.0.1 8080    
    } else { 
        drop
    }

}

But this solution is not working - all requests to VIP_IP/active-app2 are forwarded to S1/active-app How to make this redirect properly?

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi,

Here is an irule example for you :

when HTTP_REQUEST {
    switch -glob [HTTP::path] {
        "/activ-app2*" {
            HTTP::uri [string map { "app2" "app" } [HTTP::uri]]
            pool member 10.0.0.2 8080
        }
        "/activ-app*" -
        "/activ-admin*" {
          pool member 10.0.0.1 8080  
        }
        default {
            drop
        }
    }
}
0
Comments on this Answer
Comment made 1 week ago by pjedrzejak 2

Hello, still same problem, after URI change from 'app2' to 'app' F5 looks one more time in URI field and send request to S1.

It's look like uri maping trigger new HTTP_REQUEST

0
Comment made 1 week ago by Yann Desmarest 4439

Do you have LTM_policies, other rules or a default pool applied ?

Can you replace :

pool member 10.0.0.2 8080

by

node 10.0.0.2 8080

and also check that a OneConnect profile is configured on the Virtual Server ?

Regards

Yann

0
Comment made 1 week ago by f5_rock 2639

Infact you can use example like pool http_pool member 10.10.10.56 80

0