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

Filter by:
  • Solution
  • Technology
Answers

iRule for URL redirection to a pool

Hi Guys,

I’m new to iRule, can someone help with creating iRule for my requirement.

I have two URLs for PROD and DEV with same host name. I want to point PROD traffic to pool A and DEV traffic to pool B

https://abc.example.com/app/prod/zsedrcftg ==>pool A https://abc.example.com/app/dev/aserdftgy ==> pool B

I want to point based on /app/prod/* & /app/dev/*

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Edited after Stan's comment: Updated with starts_with, had missed -glob (added now)

Use any one of the below,

If else condition,

when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/app/prod/" } {
pool Prod_Pool
} else {
pool Dev_Pool
}
}

Using switch,

when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/app/prod/*" { pool Prod_Pool }
"/app/dev/*" { pool Dev_Pool }
  }
}
0
Comments on this Answer
Comment made 1 week ago by Stanislas Piron 9098

@jaikumar :

Switch command requires -glob option and wildcard in match items

In if / else, use starts_with to match the requirement

In such requirement, use HTTP::path instead of HTTP::uri

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Lots of posts with examples on how to do this, here is one: https://devcentral.f5.com/questions/irule-to-select-pool-based-on-url

In addition to the advice above, also consider ‘string tolower’ since irules are case sensitive. And what do you want to happen if there is no match in the irule. If there is no match the f5 will send traffic to the default pool assign in the vs.

0
Comments on this Answer
Comment made 1 week ago by Koti Reddy Kolli 1

Thanks Jaykumar, Piron, and Dan for your response. I will try the options given to me.

0
Comment made 1 week ago by Koti Reddy Kolli 1

Finally it's working, thanks all for your help.

0