cancel
Showing results for 
Search instead for 
Did you mean: 

Data group URIs matching & redirection to external sites

ant77
Cirrus
Cirrus

Hello All,

 

Can anyone help me with the following scenario?

 

  1. Use an i-rule and data group entries to match specific URIs, and redirect each customers to their corresponding external sites location.
  2. Add this logic to the existing iRule we are currently using.
  3. Is there any other better way to accomplish this beside an iRule? maybe Local Traffic Policy etc...We need to make it flexible and easy to

modify due to many entries.

 

Since there will be 50-100 URIs unique to each customer, We need to call on a data group with the entries from the irule so that

admins can safely add or remove URIs and their corresponding external site/locations in the future.

 

Example:

 

Customer 1 --> https://our-website.com/Customer1 ---> They need to be redirected to ---> https://marketing-site.com/Customer1/Product_info_1

 

Customer2--> https://our-website.com/Customer2 ---> They need to be redirected to ---> https://marketing-site.com/Customer2/Product_info_2

 

Customer 3 --> https://our-website.com/Customer3 ---> They need to be redirected to ---> https://marketing-site.com/Customer3/Product_info_3

 

 

 

##### Data group we need to create for a 1 to 1 matching for each customer. Each customers are different and will need

to be redirected to an external marketing site that contains their specific data...There will be 50-100 entries in this data group ####

 

ltm data-group internal DG-URI-MATCH-REDIRECT {

  records {

    /Customer1 {

      data https://marketing-site.com/Customer1/Product_info_1

    }

    /Customer2 {

      data https://marketing-site.com/Customer2/Product_info_2

    }

    /Customer3 {

      data https://marketing-site.com/Customer3/Product_info_3

    }

    /Customer4{

      data https://marketing-site.com/Customer4/Product_info_4

    }

    /Customer5 {

      data https://marketing-site.com/Customer5/Product_info_5

    }

  }

  type string

}

 

 

### Example of our Existing code we have tied to a web server VIP ####

 

when HTTP_REQUEST {

if { [active_members WEBSERVER-POOL1] < 1 } {

HTTP::redirect " http://maintenance-page.com

  } else { 

set CHECK_IP [getfield [HTTP::header values X-Forwarded-For] " " 1]

 if { !([class match $CHECK_IP eq DG-ALLOWED-IP]) } {

   if { [class match [HTTP::uri] eq DG-URIS-LIST] } {

     reject }

     }

    switch -glob [HTTP::uri] {

     "*/sub1/link1*" -

     "*/sub2/link2*" -

     "*/sub3/link3*" {

     if { ([class match $CHECK_IP eq DG-ALLOWED-IP]) } {

if { [HTTP::uri] contains "/ABC/123" } {

HTTP::redirect "https://[HTTP::host]/ABC/123"

} else {

     HTTP::redirect "https://[HTTP::host]/Main/Login

           }

}

    }

  }

 }

}

 

#######

2 REPLIES 2

JRahm
Community Manager
Community Manager

without understanding the real nature of the patterns and whether the 1, 2, 3, etc is actually part of the URL strategy or not, it's hard to give a solid answer. But updating a file as an external data-group is "easier" than updating an internal data-group or a policy. One thing I'd recommend is limit how much you actually put in the data-group though. For example, if https://marketing-site.com is consistent, there's no reason to put that in the data-group since that will only take one entry in the iRule. The same is true for the /customerX, that'll be in the request so you can just read and copy that in a single reference in the iRule.

 

HTTP::redirect "http://marketing-site.com[URI::path]/$product_info_from_datagroup"

 

 

or something like that...

ant77
Cirrus
Cirrus

Hi Jason,

 

Thanks for your answer.

 

So here is the scenario. We have about 50 - 100 unique URIs that needs to be matched to a external redirect / path for each URI.

 

Note the "mysite.com" does not change

Note the "marketing-site.com" does not change, only the URI path for each customers are different as it is tailored and design for each customer differntly.

 

The Reason why we nee do to this is it is easier for the customer to go to our site and put in "https://mysite.com/CustomerA-Data" then to type

"https://marketing-site.com/CustomerA/.blah blah/ blah blah / blah blah/" -- Which is a very long, non-user friendly URL.

 

  1. Customer A ---> https://mysite.com/CustomerB-Data (Need F5 to look at URI and redirect to an external site with a specific URL allocated for that customer)
  2. Cusomter A --> Sent to by F5 based on URI match for this customer to --> https://marketing-site.com/CustomerA/.blah blah/ blah blah / blah blah/
  3. Customer B ....same thing where they go to "https://mysite.com/CustomerB-Data" ---> https://marketing-site.com/CustomerB/blah blah/ blah blah / blah blah/

 

Can i do something like this?

 

We need to use some sort of 1 to 1 mapping where Customer A needs to be sent to https://marketing-site.com/CustomerA/blah blah/ blah blah / blah blah/

and Customer B sent to "https://marketing-site.com/CustomerB/blah blah/ blah blah / blah blah/"..

 

Do you think an LTP is better as there will be 50-100 entries?

when HTTP_REQUEST { if { [set redirect [class match -value "[HTTP::uri]" equals DG-URI-MATCH-REDIRECT]] ne ""} then { HTTP::redirect "$redirect" } }