Forum Discussion
Chip_Hudgins_64
Apr 19, 2011Nimbostratus
proxy to node based on hostname
Hello, First time posting here. I wanted to know if anyone had an idea on how to proxy to a node/server based on hostname rather than IP. I thought maybe an iRule could be used instead of a tra...
Chip_Hudgins_64
Apr 25, 2011Nimbostratus
After some searching, I found the following code that will proxy based on hostname. Unfortunately NAME::lookup/NAME::response does not return any results. I have read through the SOL on DNS resolution and tried each but without success. The result is just empty NAME_RESOLVED:
Does anyone know why the NAME::lookup does not work in the follow code:
when RULE_INIT {
The hostname to resolve to an IP address
set ::myhostname "something.domain.com"
The number of requests to use the cached DNS answer for
set ::max 100
Force a DNS lookup on the first request to get a current answer
set ::count 100
}
when CLIENT_ACCEPTED {
Increment the count of requests
incr ::count
Only look up the address every 100 resolutions
Modify this as needed by changing $::max in RULE_INIT
if { $::count >= $::max } {
set ::count 0
NAME::lookup $::myhostname
}
Set the selected node to the current resolved IP address and the port the client requested.
The port could be hard coded to any value.
node $::server_ip [TCP::local_port]
}
when NAME_RESOLVED {
log local0. "NAME_RESOLVED: [NAME::response]"
can we just use [NAME::response 0], is the response a list?
set ::server_ip [lindex [split [NAME::response] " "] 0]
}
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