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...
Brian_H__Jones_
Nimbostratus
May 16, 2014class int_host_map {
{
"test.company-a.com" { pool-company-a }
"test.company-b.com" { pool-company-b }
"test.company-c.com" { pool-company-c }
}
}
class int_redirect_map {
{
"test.company-a.com" { "test.company-a.com\testurl\login.jsp" }
}
}
rule internal_lb {
when HTTP_REQUEST {
Get URI from request
set hostName [string tolower [HTTP::host]
Select Pool from Data Class
set poolName "[class match -value -- $hostName starts_with int_host_map]
if { [HTTP::uri] equals "/" } {
set redirectTarget [class lookup $hostName int_redirect_map]
if { $redirectTarget ne "" } {
HTTP::redirect $redirectTarget
return
}
}
Assign to pool if not found show 404 error
if { $poolName ne "" } {
pool $poolName
} else {
log -noname local0.warn "URL: $hostName from: [IP::remote_addr] not found in int_host_map!"
HTTP::respond 404 content {
Not found
Not found
The requested page or resource was not found.
} } }
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