Forum Discussion
Redirect TCP connection based on hostname
hi.
I am trying to redirect a connection based on the hostname that the request came in.
I have a VS on tcpport 5222 (special programe made for us) It is not http, so I cannot use this :
when HTTP_REQUEST {
if {[HTTP::host] eq "1.domain.com" } {
node 10.20.61.21:5222
} elseif {[HTTP::host] eq "2.domain.com" } {
node 10.21.61.21:5222
} elseif {[HTTP::host] eq "3.domain.com" } {
node 10.22.61.21:5222
} elseif {[HTTP::host] eq "4.domain.com" } {
node 10.23.61.21:5222
} elseif {[HTTP::host] eq "5.domain.com" } {
node 10.24.61.21:5222
} elseif {[HTTP::host] eq "6.domain.com" } {
node 10.25.61.21:5222
} else {
HTTP::redirect "https://domain.com"
}
}
If I use the above, it will redirect to https://domain.com ...
what to use insted of HTTP::host ?? to catch the tcp-port 5222 and send it to the right node ??
Michael
2 Replies
- nitass
Employee
you have to collect payload and take an action based on data in the payload.
TCP::collect wiki https://devcentral.f5.com/wiki/iRules.tcp__collect.ashx
- eey0re
Cirrostratus
To expand on nitass' answer a little.. you can't do what you're after if it's not HTTP, unless there is something in the TCP payload that you can parse. You'd do that using TCP::collect, and it could get tricky.
An HTTP server only knows what hostname a client used to arrive because the client sends it as an HTTP header. With plain TCP, there is no way to tell.
Secondly, you say you want to "redirect" the client. You can't do that with plain TCP either. HTTP::redirect works by sending an HTTP response telling the client to go to another URL. With plain TCP, there is no way to "redirect" the client. (You could, however, use TCP::collect to make a load balancing decision - e.g. select a different pool.)
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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