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 16, 2014You should be able to significantly simplify this code:
int_host_map datagroup:
class int_host_map {
{
"test.company-a.com" { pool-company-a }
"test.company-b.com" { pool-company-b }
"test.company-c.com" { pool-company-c }
}
}int_redirect_map datagroup:
class int_redirect_map {
{
"test.company-a.com" { "/testurl/login.jsp" }
}
}iRule:
when HTTP_REQUEST {
if { ( [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..."
}
}This doesn't exactly meet your HTTP-to-HTTPS requirement though, and not 100% sure I understand what you're trying to do. If you want to redirect all HTTP to HTTPS, then you'd put a very simply redirect iRule on an HTTP VIP, and then use all of the above iRule logic on the HTTPS VIP.
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