Forum Discussion
iRule using alternate address to hit specific node
I've got a problem that's proving to be trickier than I expected. Our company hosts a variety of public facing servers running similar software, each client on a vlan of their own that follow our standard IP addressing scheme. Previously, we only served out of one datacenter and we had an iRule that let us specify a port that would then translate into a server IP. We would use that to check on the state of individual pool members without having to resort to host file trickery. Recently though, we turned up a second datacenter and are load balanced across the two with a pair of GTMs that pick a pool member (in this case, a datacenter) and that rule only works if the GTM decides to send you to the datacenter you were hoping for. Otherwise, you have to wait 10 minutes for your session to expire and hope you get the other one then.
Now that that's out of the way... the plan so far has been to create a series of new subdomains on an IP address that we assign to a new virtual server. That virtual server then has 1 iRule assigned to it that reads the new subdomains, sets a variable based on the client (used to send to the correct subnet) and replaces the header with that of the correct site (to bypass using the GTM for DNS so that we can always hit the datacenter we want). This almost works. The example I have posted below will allow me to hit the server I want, but the application depends on being served at a specific address, as does the google maps v2 api key (which is being replaced soon), so all I get is the application server's default page.
Here is an example of what I've got so far
when HTTP_REQUEST {
if { [HTTP::host] contains "ptk.first.example.org" } {
set clientsubnet 10
HTTP::header replace "ptk.first.example.org" "web.first.com"
}
elseif { [HTTP::host] contains "ptk.second.example.org" } {
set clientsubnet 11
HTTP::header replace "ptk.second.example.org" "web.second.com"
}
if {[string length [TCP::local_port]] == 4} {
set last_two [string range [TCP::local_port] 2 3]
node 10.0.$clientsubnet.1$last_two:80
}
}
To reach the other datacenter, I have another rule in place on the other site's LTMs for ran.first.example.org and servers run on 10.1.x.x. So... if I access ptk.first.example.org:8001, my host header is changed to web.first.com and I am directed to the node 10.0.10.101 which is what I want. However, the web application and the google maps API key both know that I'm still actually at ptk.first.example.org and refuse to work.
Anyway, does anyone know of a way to pass a host header in a way that the web application acknowledges it or a way to just replace the whole URL without then falling back on the GTM or a hosts file to resolve the DNS? Am I going about this problem the entirely wrong way? Thank you.
- nitassEmployeeshouldn't it be HTTP::header replace Host "web.first.com" and HTTP::header replace Host "web.second.com"?
- aberrati0n_902NimbostratusThanks, that helped a lot. It's almost working perfectly now!
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