Forum Discussion
Redirect + datagroup
Hi,
I have a datagroup... for example
/prueba.com := /prueba.com/home
I have used HTTP::redirect and HTTP::respond 301 Location "..." and It doesn't work.
HTTP::respond 301 Location "http://[class match -value [HTTP::host][HTTP::uri] eq dg_redirect]"
Would you know what I am doing bad?
11 Replies
- What_Lies_Bene1
Cirrostratus
I couldn't say exactly why but this won't work, you're doing too much at once. This should;
when HTTP_REQUEST { Compare the request URI with the strings in the uri-dg data group and populate the variable: redirect with the associated value if there is a match set redirect [class match -value [HTTP::uri] equals dg_redirect] As long as our variable: redirect isn't empty, perform the redirect if { $redirect ne "" } { HTTP::redirect "http://[HTTP::host]$redirect" } If there wasn't a match and variable: redirect is empty, do something else instead else { log local0. "No redirect occurred for: [HTTP::uri]" } } - Arie
Altostratus
Keep in mind that data groups become temporarily unavailable when you save them. You'll want to build a catch into your code to make sure that the data group exists to avoid an error.
There are two conditions you may encounter for a brief period of time when you save it:
- The data group doesn't exist yet as it's being recreated.
- Not all data has been written to the group yet so some redirects will not work temporarily.
This happens for only a brief moment (the duration depends on the number of entries in the group), but it's something to keep in mind.
- What_Lies_Bene1
Cirrostratus
Hey Arie. I wasn't aware of that, I hate to question you but are you sure that's still the case?
Updated iRule (untested) incorporating the check;when HTTP_REQUEST { Compare the request URI with the strings in the uri-dg data group and populate the variable: redirect with the associated value if there is a match if { class exists dg_redirect } { set redirect [class match -value [HTTP::uri] equals dg_redirect] As long as our variable: redirect isn't empty, perform the redirect if { $redirect ne "" } { HTTP::redirect "http://[HTTP::host]$redirect" } If there wasn't a match and variable: redirect is empty, do something else instead else { log local0. "No redirect occurred for: [HTTP::uri]" } } } - nitass
Employee
i understand these are discussion topics Arie has worked on.
Datagroup access during a datagroup update
https://devcentral.f5.com/community/group/aft/1172712/asg/50
Data Group (Class) unavailable during updates, causing errors
https://devcentral.f5.com/community/group/asg/50/afs/desc/aft/2160953/showtab/groupforums - What_Lies_Bene1
Cirrostratus
Thanks Nitass.
Based on what I read, should my class check look like this instead;if { [class exists dg_redirect] } { - hoolio
Cirrostratus
Unfortunately, this is still an issue. Please do open cases with F5 Support and request to have your case attached to BZ381100 to raise the visibility of this bug.
Aaron - What_Lies_Bene1
Cirrostratus
Shame, thanks for the confirmation Aaron. - nitass
Employee
Based on what I read, should my class check look like this instead; i never tested but if i do not read bug detail wrongly, it does not say we delete data group but just entry in data group. anyway, Aaron and Arie may be able to provide more information because they have worked on it.
Bug 381100 - Data group / class updates are not processed atomically by tmm - hoolio
Cirrostratus
When I tested the datagroup always existed, but the elements were removed individually and then added back individually. So you'll have an incomplete data group for the change period but the object itself should always exist.
If it's critical that the datagroup contents always be whole during production hours, you'd want to limit changes to the datagroup to a maintenance window.
Aaron - What_Lies_Bene1
Cirrostratus
Thanks gents.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com