Forum Discussion
Elias_O_16228
Nimbostratus
Apr 22, 2013Redirecting request based on port number
I have two application servers as pool members to multiple pools. I want to be able to load balance based on port.
For example, If a user click first link, load balance staging pool. If user is...
Kevin_Stewart
Employee
Apr 23, 2013If you JUST want to match the port number, then you can do that using the TCP::local_port command:
when HTTP_REQUEST {
switch [TCP::local_port] {
"8088" { pool Stagin_Pool }
"8089" { pool Management_Pool }
"8090" { pool Development_Pool }
"8091" { pool Test_Lab_Pool }
default { pool Production_Pool }
}
}
If you need to match the whole request (host, port, and uri) then you'd need something like this:
"[string tolower [HTTP::host]]:[TCP::local_port][string tolower [HTTP::uri]]"
This won't capture the protocol specifier (ex. "http://"), so you'll need to remove it from the evaluation. Considering that all of the hosts are the same, you can probably skip the [HTTP::host] evaluation as well. Also, if the port and URI are specific to a service (ex. 8088 and /tuesday), then you might also want to consider just evaluating one or the other.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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