Forum Discussion
Brian_H__Jones_
Nimbostratus
May 16, 2014Irule for Load-Balancing Host Headers and Redirects
I have a customer that is moving to my F5, from a CSS. It's a migration, and the way the CSS is configured, I do not want to simply convert the rules from the CSS over the F5 as there were a lot of w...
Kevin_Stewart
Employee
May 19, 2014I'd probably use a data group to define what Hosts need to be HTTP vs. HTTPS.
HTTP VIP iRule:
when HTTP_REQUEST {
if { [class match [string tolower [HTTP::host]] equals my_https_dg] } {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
} elseif { ( [HTTP::uri] equals "/" ) and ( [class match [string tolower [HTTP::host]] equals int_redirect_map] ) } {
HTTP::redirect "http://[HTTP::host][class match -value [string tolower [HTTP::host]] equals int_redirect_map]"
} elseif { [class match [string tolower [HTTP::host]] equals int_host_map] } {
pool [class match -value [string tolower [HTTP::host]] equals int_host_map]
} else {
HTTP::respond 404 content "...data..."
}
}
where "my_https_dg" is a string-based data group containing all of the host names that have to be HTTPS.
HTTPS VIP:
when HTTP_REQUEST {
if { ( [HTTP::uri] equals "/" ) and ( [class match [string tolower [HTTP::host]] equals int_redirect_map] ) } {
HTTP::redirect "https://[HTTP::host][class match -value [string tolower [HTTP::host]] equals int_redirect_map]"
} elseif { [class match [string tolower [HTTP::host]] equals int_host_map] } {
pool [class match -value [string tolower [HTTP::host]] equals int_host_map]
} else {
HTTP::respond 404 content "...data..."
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects