Forum Discussion
iRule or LTM Policy to pre-fix desired www. sites
Understood. I created a new datagroup Datagroup_exclude and placed the subdomain sites in it. I guess I went full circle back to my original question now though. How would you go about checking to see if it needs to be modified with www and exlude those in the new datagroup?
What about this solution? Use the same Datagroup1, and define the allowed hosts as 'strict' if they shouldn't be modified by the iRule. In the example below 'nielske.nl' isn't allowed to be modified.
And use Datagroup1 with the following iRule.
when HTTP_REQUEST {
if { [class match [HTTP::host] equals Datagroup1] } {
if { !([HTTP::host] starts_with "www.") && !([class lookup [HTTP::host] Datagroup1] equals "strict") } {
log local0. "[HTTP::host] doesn't starts_with www. and isn't defined as strict; redirect allowed"
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
}
} else {
HTTP::respond 403
}
}- DoubleJzOct 25, 2023
Nimbostratus
I like that and thats similar to what I was trying to come up with prior posting on here. Also to be clear, the inner if statement doesn't need an else. It if doesn't match any constraints it will just leave that inner if statement and continue on in the outter if statement, right?
when HTTP_REQUEST { if { [class match [HTTP::host] equals Datagroup1] } { if { !([HTTP::host] starts_with "www.") && !([class lookup [HTTP::host] Datagroup1] equals "strict") } { HTTP::redirect "https://www.[HTTP::host][HTTP::uri]" } pool prod_sites } else { HTTP::respond 403 } }- Oct 26, 2023
Yes, this looks alright to me.
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