Post of the Week: HTTP Redirect using Datagroups
In this "Post of the Week" video, we discuss HTTP redirects and how to use datagroups and iRules to do these redirects. If you have lots of URLs to redirect, then you might want to consider using something like this. Enjoy!
Resources
Developing iRules for BIG-IP21 Comments
- dragonflymr
Cirrostratus
Hi,
 
Check ProxyPass (https://devcentral.f5.com/s/articles/proxypass-v10-v11), you will find good example of such feature.
 
Piotr
 
- Reddy1
Altostratus
Sure
- Reddy1
Altostratus
Can this works?
if [matchclass [HTTP::uri] equal REDIRECT] { set uri [matchclass -value [HTTP::uri] equals REDIRECT] HTTP::uri $uri pool MY_Pool }
Note:- example the data-group has entry , string:/x/y value:/z
- Stanislas_Piro2
Cumulonimbus
REddy : some curly brackets are missing
you can use this code
if {[set [matchclass -value [HTTP::uri] equals REWRITE]] ne ""} { HTTP::uri $uri pool MY_Pool } - dragonflymr
Cirrostratus
Hi,
@Stanislass: Is it not advised to use
instead ofclass match
?matchclassThis code is good, but I still think that it is worth checking ProxyPass and use it as base to create iRule resolving not only URI modification but as well pool selection via Data Group.
Piotr
- Stanislas_Piro2
Cumulonimbus
Your right, I did not see this!
URI rewriting is never a good idea, because one consequence is response rewriting may be required. And response rewriting is the worst configuration...
- dragonflymr
Cirrostratus
Well, I know your approach :-), still as fast remedy I had to work figure out how to create what I need based on ProxyPass - seem to be working quite OK at least at header and cookie rewriting for responses.
Piotr
- jmolchin_47123
Nimbostratus
Is it possible to reverse proxy a VS that is using a datagroup to redirect URL's? I don't want clients to proxy behind an F5 interface not access the URL directly. The VS is not using a default pool, the clients destination is in the datagroup.
- Reddy1
Altostratus
For some reason the below irule not working, if {[class match $uri eq DATAGROUP]} { set new_uri [class match -value $old_uri eq DATAGROUP] HTTP::uri "$new_uri" pool $XYZ }
I need to verify the incomming uri checked against the Data-group before the value is assigned. Do i need to change it to set new_uri "[class match -value $old_uri eq DATAGROUP]" ?
- dragonflymr
Cirrostratus
Hi,
Assuming that you using
in$uri
and then useif
inside this will not work, so I suggest something like that:$old_uriif ( [set new_uri [class match -value [HTTP::uri] eq DATAGROUP]] ne ""} { HTTP::uri "$new_uri" pool $XYZ }It is assuming that your DG is set like that: old_uri := new_uri
- old_uri - key name you use to match with DG
- new_uri - new URI that should be set if there is match on old_uri
Piotr
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)