Forum Discussion
Matt_Mueller_10
Nimbostratus
Oct 23, 2008Help - starts_with subdomain pool routing?
I'm trying to write an irule that will pool information based on the incoming subdomain\domain used. For example, domain1 will have many subdomains, can I route the traffic to a desired pool based of...
hoolio
Cirrostratus
Oct 24, 2008Maybe something like this? I'm not sure if you're using this rule on an HTTPS VIP which ftp.newdomain.com resolves to or not. If you do, then you shouldn't redirect requests made to ftp.newdomain.com with a uri of / to https://ftp.newdomain.com/ or you'll get a redirect loop.
when HTTP_REQUEST {
log local0. "[IP::client_addr]:TCP::client_port]: New request to [HTTP::host], [HTTP::uri]"
Checks the URI and forces to all lowercase for the check first for subdomain1
switch [string tolower [HTTP::host]] {
"subdomain1.newdomain.com" {
if { [HTTP::path] eq "/"}{
log local0. "[IP::client_addr]:TCP::client_port]: Matched subdomain1.newdomain.com with URI of /. Redirecting to https"
HTTP::redirect "https://subdomain1.newdomain.com/virtualdir/"
return
} else {
log local0. "[IP::client_addr]:TCP::client_port]: Matched subdomain1.newdomain.com with URI not /. Using pool subomain1"
pool subdomain1
return
}
}
"ftp.newdomain.com" {
if { [HTTP::path] eq "/"}{
log local0. "[IP::client_addr]:TCP::client_port]: Matched ftp.newdomain.com with URI of /. Redirecting to https"
HTTP::redirect "https://ftp.newdomain.com/new_uri/"
return
} else {
log local0. "[IP::client_addr]:TCP::client_port]: Matched ftp.newdomain.com with URI not /. Using pool newdomainftp"
pool newdomainftp
return
}
}
}
If we got here, no condition was matched, so use default pool
pool errorpage
log local0. "[IP::client_addr]:TCP::client_port]: No match. Using default pool"
}
Aaron
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