cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

Need help redirecting hundreds of host:uris to differentHOST:differentURI using datagroup and irule

Danny_Arroyo
Cirrus
Cirrus

Hi All.

 

I am using a BIG IP LTM v15.1.0.4

 

We have a file of 300 redirects that need to be handled by the F5 for one specific VIP. Its basically ONEHOST:ONEURI to ANOTHERHOST:ANOTHERURI. I have been unsuccessful in getting a datagroup and irule working to handle these redirects.

 

i have read through several threads and watched several videos but none of what I have learned and put in place is working. I figured out how to import the file of redirects to create the datagroup. However the irule does not seem to match anything.

 

As a troubleshooting step, I created a string datagroup using the GUI with one "string 😆 value" combination, but I get the same result (so Im thinking the problem is my irule). Here are two examples of what I put into the irule (niether worked):

 

when HTTP_REQUEST {       if {[set redir_url [class match -value -- [string tolower [HTTP::host][HTTP::uri]] equals datagroup]] ne ""}{         HTTP::respond [getfield redir_url " " 1] Location [getfield redir_url " " 2]       } } when HTTP_REQUEST {     if {[set redir_url [class match -value -- [string tolower [HTTP::host][HTTP::uri]] equals datagroup]] ne "" }{     HTTP::redirect $redir_url     } }

 

I also tried changing "equals" to "contains" and also "like" but that didn't help either.

 

In my datagroup, I tried "https://mycompany.com/linkA" := "https://anothercompany.com/newlink". I tried with and without the "https://", but cant seem to get a match

 

I'm hoping I have a simple syntax error that someone can help me with. Any advice is appreciated.

 

1 ACCEPTED SOLUTION

 

 

I dont see any syntax issue. But I see problem in your data group.

In my datagroup, I tried "https://mycompany.com/linkA" := "https://anothercompany.com/newlink". I tried with and without the "https://", but cant seem to get a match

I see you have put "https://mycompany.com/linkA", where the uri linkA is having A as caps.

So the Irule is converting everything to small case & when it does, it looks for record ""https://mycompany.com/linka" but it can't find one. So it wont redirect.

 

If you are doing string to lower in your irule, make sure you add your datagroup records in smaller case too.

This is a common mistake to ignore. I've done multiple times.

 

Please keep us posted & mark the thread as closed if it answers.

View solution in original post

4 REPLIES 4

 

 

I dont see any syntax issue. But I see problem in your data group.

In my datagroup, I tried "https://mycompany.com/linkA" := "https://anothercompany.com/newlink". I tried with and without the "https://", but cant seem to get a match

I see you have put "https://mycompany.com/linkA", where the uri linkA is having A as caps.

So the Irule is converting everything to small case & when it does, it looks for record ""https://mycompany.com/linka" but it can't find one. So it wont redirect.

 

If you are doing string to lower in your irule, make sure you add your datagroup records in smaller case too.

This is a common mistake to ignore. I've done multiple times.

 

Please keep us posted & mark the thread as closed if it answers.

Danny_Arroyo
Cirrus
Cirrus

Hi Jalkumar,

 

Thanks for your response. You are 100% correct. I adjusted accordingly and it is working. Thanks!!

 

Danny_Arroyo
Cirrus
Cirrus

Hi Jalkumar,

 

One more related question.

 

How can I check the datagroup file (in the F5 filesystem) after it is successfully imported from an External file to the F5 successfully?

Yea you can goto /config/filestore/files_d/Common_d/data_group_d path and check there.

The GUI is pretty straight, System > File Management > Data Group File List.

 

Please mark the thread as solution provided.