17-Jun-2020 11:08
Hello All,
Can anyone help me with the following scenario?
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"
}
}
}
}
}
}
#######
18-Jun-2020
08:07
- last edited on
04-Jun-2023
21:24
by
JimmyPackets
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...
18-Jun-2020
08:31
- last edited on
05-Jun-2023
23:05
by
JimmyPackets
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.
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"
}
}