Forum Discussion
Node autoselection using DNS
Hi N,
you should add some additional error handlings to your iRule in the case the browser doesn't send a HOST-Header value or in the case the DNS Server can't resolve the provided HOST-Name.
when HTTP_REQUEST {
if { [HTTP::host] ne "" } then {
set ips [lindex [RESOLV::lookup -a [getfield [HTTP::host] ":" 1]] 0]
log local0.debug "Debug: Resolved address for \"[getfield [HTTP::host] ":" 1]\" = \"$ips\""
if { $ips ne "" } then {
node $ips [TCP::local_port]
} else {
HTTP::respond 504 content "Bad Request - non-existent HOST value"
}
} else {
HTTP::respond 504 content "Bad Request - empty HOST value"
}
}
Note: If the iRule above reports a "Bad Request - non-existent HOST value" in your environment, then make sure you've followed the steps outlined in K12225 [click me]. Alternatively to K12225 you could also setup a dedicated DNS Virtual Server and Pool to access and balance your DNS resolvers. Then use
to perform the DNS resolution via your just created Virtual Server...[RESOLV::lookup @VS_MyDNS -a [getfield [HTTP::host] ":" 1]] 0]
Cheers, Kai
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
